LoginSignup
3

More than 5 years have passed since last update.

InnoSetupでMutex

Posted at

InnoSetupでsetup.exeの同時起動を排他するにはMutexを使います。
コードはこんなところでしょうか。

[Code]
const
  MySetupMutex = 'MySetupsMutexName';

function InitializeSetup: Boolean;
begin
  Result := not CheckForMutexes(MySetupMutex);
  if Result then begin
    CreateMutex(MySetupMutex)
  end else begin
    MsgBox('Another instance is running. Setup will exit.', mbError, MB_OK);
  end;
end;

InnoSetup 5.5.6 からは[Setup]セクションに1行書けばOK.

[Setup]
SetupMutex=MySetupsMutexName,Global\MySetupsMutexName

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3