目前訪問LocalLow我用這個:AppData LocalLow常量?
{%USERPROFILE}\AppData\LocalLow
但我想知道是否有用於在INNO一組常數,因爲這兩個Roaming
和Local
有一個。
目前訪問LocalLow我用這個:AppData LocalLow常量?
{%USERPROFILE}\AppData\LocalLow
但我想知道是否有用於在INNO一組常數,因爲這兩個Roaming
和Local
有一個。
AppData\LocalLow
沒有常數。
您可以使用Pascal腳本來解決它。
要解決「LocalLow」,必須使用SHGetKnownFolderPath
。
另請參閱Detect the location of AppData\LocalLow。
由於在Unicode Inno Setup中缺少(廣泛的)PChar
類型,因此實施涉及很少的黑客行爲。
const
MAX_PATH = 260;
AppDataLocalLowGUID = '{A520A1A4-1780-4FF6-BD18-167343C5AF16}';
{ There's no PChar in Unicode Inno Setup, }
{ pretend the function returns a pointer to an Integer }
function SHGetKnownFolderPath(rfid: TGUID; dwFlags: DWORD; hToken: THandle;
var ppszPath: Integer): Integer;
external '[email protected] stdcall';
{ And allow the Integer to be copied to string }
function StrCpy(Dest: string; Source: Integer): Integer;
external '[email protected] stdcall';
{ And allow the Integer pointer to be released }
procedure CoTaskMemFreeAsInteger(pv: Integer);
external '[email protected] stdcall';
function GetAppDataLocalLow: string;
var
Path: Integer;
I: Integer;
begin
if SHGetKnownFolderPath(StringToGUID(AppDataLocalLowGUID), 0, 0, Path) = 0 then
begin
{ The path should not be longer than MAX_PATH }
SetLength(Result, MAX_PATH);
StrCpy(Result, Path);
CoTaskMemFreeAsInteger(Path);
{ Look for NUL character and adjust the length accordingly }
for I := 1 to MAX_PATH do
begin
if Result[I] = #0 then
begin
SetLength(Result, I - 1);
Break;
end;
end;
end;
end;
如果您需要使用非Code
部分的路徑(Pascal腳本之外),你可以使用一個scripted constant:
[Files]
Source: myfile.txt; DestDir: {code:GetAppDataLocalLow}
而且你需要更改功能簽名採取虛擬參數:
function GetAppDataLocalLow(Param: string): string;
例如,刪除文件時卸載m LocalLow with INNO:
[UninstallDelete]
Type: filesandordirs; Name: "{userappdata}\..\LocalLow\MyFile.txt"
不幸的是沒有,因爲在Windows中LocalLow沒有環境變量。雖然你可能想看看[那個主題](http://stackoverflow.com/questions/4494290/detect-the-location-of-appdata-locallow)。編輯:您可能想要連接Evnironmental變量與字符串解決方案。 'S:= ExpandConstant('{%LocalAppData}'+'Low');' – RobeN
是的,很多解決方法,但沒有實際的常數。另一方面,如果沒有環境變量,程序如何使用? –
程序使用'SHGetKnownFolderPath'。 Inno安裝程序不使用環境變量來解析常量。它主要使用(不建議使用)'SHGetFolderPath'。它只爲'userpf'和'usercf'使用'SHGetKnownFolderPath',因爲'SHGetFolderPath'(它不支持'LocalLow')不支持。 –