gpt4 book ai didi

windows - Inno Setup 中 AppData\LocalLow 的常量?

转载 作者:行者123 更新时间:2023-12-03 11:06:23 26 4
gpt4 key购买 nike

当前访问LocalLow我用这个:

{%USERPROFILE}\AppData\LocalLow
但我想知道 Inno Setup 中是否有一个常量,因为 RoamingLocal有一个。

最佳答案

AppData\LocalLow 没有常数.

您可以使用 Pascal Scripting 来解决它。

要解决“LocalLow”,必须使用 SHGetKnownFolderPath .
另见 Detect the location of AppData\LocalLow .

由于缺乏(宽)PChar,实现涉及很少的黑客攻击。输入 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 'SHGetKnownFolderPath@Shell32.dll stdcall';

{ And allow the Integer to be copied to string }
function StrCpy(Dest: string; Source: Integer): Integer;
external 'StrCpyW@Shlwapi.dll stdcall';

{ And allow the Integer pointer to be released }
procedure CoTaskMemFreeAsInteger(pv: Integer);
external 'CoTaskMemFree@Ole32.dll 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;

如果需要使用非 Code中的路径部分(Pascal Script 之外),您可以使用 scripted constant :
[Files]
Source: myfile.txt; DestDir: {code:GetAppDataLocalLow}

并且您需要更改函数签名以采用虚拟参数:

function GetAppDataLocalLow(Param: string): string;

关于windows - Inno Setup 中 AppData\LocalLow 的常量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35219952/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com