如何在Inno Setup中检查64/32位

3
我想进入一个文件夹。如果是64位系统,则为Program Files (x86),如果是32位,则为Program Files。如何在Inno setup中实现。
这是我尝试过的代码(但没有成功):
procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox('Do you want to delete saved games?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mres = IDYES then
          if ProcessorArchitecture = paIA64 then
            begin
               if IsWin64 then
                DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files (x86)\MY PROJECT'), True, True, True);
          else
                DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files\MY PROJECT'), True, True, True);
          end;
      end;
  end;
end;
1个回答

5

您的beginend不匹配。在else之前应该没有分号。

而且,您不应该关心处理器架构(ProcessorArchitecture),而只需要关注 Windows 是否为 64 位(IsWin64)。

procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox('Do you want to delete saved games?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mres = IDYES then
        begin
          if IsWin64 then
            DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files (x86)\MY PROJECT'), True, True, True)
          else
            DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files\MY PROJECT'), True, True, True);
        end;
      end;
  end;
end;

1
@Kushal,这将在具有本地化文件夹名称的系统上失败。无论如何,您需要访问虚拟存储文件夹表明您正在写入您没有足够访问权限的文件夹(当您尝试写入程序文件时,它是UAC虚拟化将您的东西存储在那里)。要解决问题,请停止从您的(非提升)应用程序写入程序文件夹,并使用用于存储用户数据的文件夹,例如应用程序数据。 - TLama
@TLama,对不起我犯了一个错误。请查看这个问题 - Kushal
你还不能改变你的应用程序吗?我敢打赌虚拟商店文件夹没有常量(很可能是因为你不应该访问它们)。 - TLama

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接