【问题标题】:Problems in deleting a dll at uninstall using INNO setup使用 INNO 安装程序在卸载时删除 dll 的问题
【发布时间】:2011-07-12 17:55:00
【问题描述】:

我正在使用 GameuxInstallHelper.dll 在安装时使用 Games Explorer 注册我的游戏。

但由于某些原因,卸载后 dll 仍保留在我的应用程序文件夹中,但仅在 Win XP 上。在 Win 7 和 Vista 上,所有文件都会被删除。

使用的代码:

function CheckXPOs(): Boolean;
begin
  if GetWindowsVersion shr 24 < 6 then Result:=TRUE
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  if CurUninstallStep = usUninstall then
    begin
      #ifdef AddToGameExplorer
      if not CheckXPOs then
        begin
          RetrieveGUIDForApplication(ExpandConstant('{app}'+GE_resource), GUID);
          RemoveFromGameExplorer(GUID);
          RemoveTasks(GUID);
          UnloadDll(ExpandConstant('{app}\GameuxInstallHelper.dll'));
        end;
      #endif
    end;
    case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox(ExpandConstant('{cm:removemsg}'), mbConfirmation, MB_YESNO)
          if mres = IDYES then
            DelTree(ExpandConstant('{app}'), True, True, True);
      end;
     end;
end;

知道为什么 dll 在 XP 操作系统上没有被删除,我该如何删除它? 我在卸载 dll 后尝试了 DeleteFile 函数,我还尝试创建另一个函数来搜索那个特定的 dll,但没有任何帮助我解决问题。 而且这个 dll 没有被使用,因为操作系统让我手动删除它。

【问题讨论】:

  • @stukelly 确实改变了代码中的某些内容?因为我看不到任何明显的差异。
  • 不,我刚刚添加了 inno-setup 标签。
  • 您提到您尝试使用 DeleteFile,但您没有解释这样做时是否收到错误消息。卸载过程中可能正在使用该文件,但如果 DeleteFunction 失败,您可以通过检查最后一个操作系统错误来了解它。
  • 好的,我决定将它发送到 {sys},而不是将 dll 复制到我的应用程序文件夹。但是当我卸载我的程序时,我仍然收到那个消息框,上面写着“我的程序卸载完成。某些元素无法删除。这些可以手动删除。”。有趣的是我的应用程序文件夹不再存在,它正在被删除。所以现在我只需要摆脱那个消息框。有什么想法吗?

标签: dll inno-setup uninstallation


【解决方案1】:

您应该在“not CheckXPOs”块之后卸载 dll。

if not CheckXPOs then
begin
  RetrieveGUIDForApplication(ExpandConstant('{app}'+GE_resource), GUID);
  RemoveFromGameExplorer(GUID);
  RemoveTasks(GUID);
end;
UnloadDll(ExpandConstant('{app}\GameuxInstallHelper.dll'));

另一种方法是在从 GameuxInstallHelper.dll 加载的所有函数的声明中添加 "delayload" 选项

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-21
    • 2021-01-07
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-28
    相关资源
    最近更新 更多