Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Setup]
- AppId=2336BF63-DF20-445F-AAE6-70FD7E2CE1CF
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}\My Program
- [Code]
- #ifdef UNICODE
- #define AW "W"
- #else
- #define AW "A"
- #endif
- const
- ERROR_ALREADY_EXISTS = 183;
- function CreateMutex(lpMutexAttributes: LongWord; bInitialOwner: BOOL; lpName: string): THandle;
- external 'CreateMutex{#AW}@kernel32.dll stdcall';
- function InitializeSetup: Boolean;
- begin
- Result := True;
- // it's quite handy to use the AppId directive to be the mutex name because it should be unique;
- // if the CreateMutex function call fails, let the setup start no matter what happened; if this
- // call succeeded, and the mutex already exists, there is another process that created it - let
- // the setup exit telling this to the user
- if (CreateMutex(0, False, '{#SetupSetting('AppId')}') <> 0) and (DLLGetLastError = ERROR_ALREADY_EXISTS) then
- begin
- Result := False;
- MsgBox('Another instance of the setup with this AppId is running.', mbInformation, MB_OK);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement