@@ -32,6 +32,10 @@ OutputBaseFilename=TinyDRPC-setup
3232Compression = lzma
3333SolidCompression = yes
3434WizardStyle = modern
35+ AppMutex = Global\{#MyAppName }
36+
37+ [UninstallDelete]
38+ Type : files ; Name : " {app} \TinyDRPC.ini"
3539
3640[Languages]
3741Name : " english" ; MessagesFile : " compiler:Default.isl"
@@ -54,9 +58,35 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
5458function InitializeSetup : Boolean;
5559begin
5660#ifdef Dependency_Path_NetCoreCheck
57- Dependency_AddDotNet80;
5861 Dependency_AddDotNet80Desktop;
5962#endif
6063
6164 Result := True;
65+ end ;
66+
67+ function IsAppRunning (const FileName: string): Boolean;
68+ var
69+ FWMIService: Variant;
70+ FSWbemLocator: Variant;
71+ FWbemObjectSet: Variant;
72+ begin
73+ Result := false;
74+ FSWbemLocator := CreateOleObject(' WBEMScripting.SWBEMLocator' );
75+ FWMIService := FSWbemLocator.ConnectServer(' ' , ' root\CIMV2' , ' ' , ' ' );
76+ FWbemObjectSet := FWMIService.ExecQuery(Format(' SELECT Name FROM Win32_Process Where Name="%s"' ,[FileName]));
77+ Result := (FWbemObjectSet.Count > 0 );
78+ FWbemObjectSet := Unassigned;
79+ FWMIService := Unassigned;
80+ FSWbemLocator := Unassigned;
81+ end ;
82+
83+ function InitializeUninstall (): Boolean;
84+ begin
85+ if IsAppRunning(' {#MyAppExeName}' ) then
86+ begin
87+ MsgBox(' The TinyDRPC is currently running. Please close it before continuing.' , mbError, MB_OK);
88+ Result := False;
89+ end
90+ else
91+ Result := True;
6292end ;
0 commit comments