gpt4 book ai didi

c++ - 卸载基于 Inno 的设置时从用户配置文件中删除文件

转载 作者:行者123 更新时间:2023-11-30 04:27:18 25 4
gpt4 key购买 nike

是否可以从此文件夹中删除文件以及如何删除?

目前我有这个不起作用

[UninstallDelete]
Type: files; Name: "{userappdata}\Roaming\Myapp\*";
Type: files; Name: "{commonappdata}\Roaming\Myapp\*";
Type: files; Name: "{app}\*.*";

[Code]
/////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;


/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;


/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString

// default return value
Result := 0;

// get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;

/////////////////////////////////////////////////////////////////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then
begin
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end;
end;

最佳答案

虽然 Inno 可以从运行卸载程序的用户的配置文件中删除文件,但它不能触及任何其他用户的配置文件。

如果尝试运行卸载程序的用户是受限用户,它将询问管理员详细信息,因此任何 {user...} 常量都将解析为管理员用户,而不是受限用户用户。

在这种情况下,您最好的选择是保留用户的任何配置和数据,以防他们想要重新安装或拥有漫游配置文件。另请注意,在上面的代码中,旧设置在升级过程中被删除,这将触发“删除所有用户的数据”选项。我确定这不是您想要的...

关于c++ - 卸载基于 Inno 的设置时从用户配置文件中删除文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11006934/

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