问题描述
当前要访问 LocalLow
,我使用此方法:
Currently to access LocalLow
I use this:
{%USERPROFILE}\AppData\LocalLow
但是我想知道Inno Setup中是否存在常量,因为两个漫游
和 Local
有一个。
But I would like to know if there's a constant for that in Inno Setup, since both Roaming
and Local
have one.
推荐答案
AppData\LocalLow
没有常量。
您可以使用Pascal脚本来解决它。
You may use Pascal Scripting to resolve it.
要解决 LocalLow,必须使用。
另请参见。
To resolve the "LocalLow", one has to use SHGetKnownFolderPath
.
See also Detect the location of AppData\LocalLow.
由于Unicode Inno Setup中缺少(宽) PChar
类型。
The implementation involves few hacks, due to a lack of (wide) PChar
type in Unicode Inno Setup.
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 }
SetLength(Result, Pos(#0, Result) - 1);
end;
end;
如果您需要在非代码
部分(在Pascal脚本之外),您可以使用:
If you need to use the path in non-Code
section (outside of the Pascal Script), you can use a scripted constant:
[Files]
Source: myfile.txt; DestDir: {code:GetAppDataLocalLow}
您需要更改函数签名以获取虚拟参数:
And you need to change the function signature to take a dummy parameter:
function GetAppDataLocalLow(Param: string): string;
这篇关于Inno Setup中AppData\LocalLow的常量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!