0

At the very beginning of the script I have these lines of code:

#define ISSI_Splash "C:\InnoSetupProject\Images\client.bmp"                    
#define ISSI_Splash_T 3                                                                         
#define ISSI_Splash_X 500                                                                       
#define ISSI_Splash_Y 220

In my [Setup] section I add the directive:

AppMutex=ABClientLaunchMutex

Then in the [Code] section I create the mutex:

[Code]
function ISSI_InitializeSetup : Boolean;
begin
  Result := True;
  CreateMutex('ABClientLaunchMutex');
end;

#define ISSI_InitializeSetup

and those 2 lines of code are at the end of the script:

#define ISSI_IncludePath "C:\ISSI" 
#include ISSI_IncludePath+"\_issi.isi"

But this does not work as one would expect. Whenever I launch the installer it immediately shows me the mutex's message that my apllication is already running, but this is not true. I haven't created my mutex in the Global namespace, so I don't need to use the Global\ prefix. If I comment those 4 #define directives at the beginning then the mutex won't work at all.
Could you please tell me what is wrong with my code so it works like that?

4

1 回答 1

2

如果我的应用程序已经安装并启动,如果想要阻止安装程序运行,我需要使用 AppMutex。

我认为您的错误是当您的应用程序应该执行此操作时,您正在设置脚本本身中创建互斥锁。

我的脚本中AppMutex只有一次:

[setup]
AppMutex=xxxyyyzzz

正如文档所述:

使用此指令需要您向应用程序添加代码,该代码会创建一个具有您在此指令中指定的名称的互斥锁。

该文档提供了示例。这是我使用 Visual C++ MFC 项目的方法:

BOOL CMeetingScheduleAssistantApp::InitInstance()
{
    CString strMutex;

    stMutex.LoadString(IDS_APP_MUTEX);

    m_hMutex = ::CreateMutex(nullptr, FALSE, strMutex);

    ...
    ...
}
于 2020-03-31T16:39:10.940 回答