Skip to content

Commit c4391e5

Browse files
committed
Added application mutex and mutex detection support.
1 parent f065354 commit c4391e5

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

installers/win-innosetup/yourapp.iss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
; Basic Inno Setup script.
2-
; (C) 2019 CubicleSoft. All Rights Reserved.
2+
; (C) 2021 CubicleSoft. All Rights Reserved.
33

44
; Adjust these defines for your app.
55
#define BusinessName "Your Business or Name"
66
#define BusinessURL "http://www.yourwebsite.com/"
77
#define AppName "Your App"
8+
#define AppMutex "Your Business or Name_Your App"
89
#define AppFilename "Your-App"
910
#define AppVer "1.0"
1011
#define AppURL "http://www.yourwebsite.com/product/"
11-
#define AppCopyright "(C) 2019 Your Business or Name"
12+
#define AppCopyright "(C) 2021 Your Business or Name"
1213
#define SupportURL "http://www.yourwebsite.com/contact/"
1314
#define AppBase "yourapp"
1415

@@ -44,6 +45,7 @@ AppPublisherURL={#BusinessURL}
4445
AppUpdatesURL={#AppURL}
4546
AppSupportURL={#SupportURL}
4647
AppCopyright={#AppCopyright}
48+
AppMutex={#AppMutex}
4749
SourceDir=..\..
4850
#ifdef PHP_64
4951
ArchitecturesInstallIn64BitMode=x64
@@ -107,7 +109,7 @@ end;
107109
function InitializeSetup() : Boolean;
108110
var
109111
MsgResult : Integer;
110-
ErrCode: integer;
112+
ErrCode: Integer;
111113
begin
112114
// Check for the correct VC++ Redistributables.
113115
if ((NOT Is64BitInstallMode) AND (NOT FileExists(ExpandConstant('{syswow64}') + '\{#VCDetect}'))) then begin
@@ -167,10 +169,10 @@ Source: "support\*"; Excludes: "mac\,nix\"; DestDir: "{app}\support"; Flags: cre
167169
Source: "extensions\*"; Excludes: "README.md"; DestDir: "{app}\extensions"; Flags: createallsubdirs recursesubdirs skipifsourcedoesntexist
168170
Source: "www\*"; Excludes: "README.md"; DestDir: "{app}\www"; Flags: createallsubdirs recursesubdirs
169171
#ifdef PHP_32
170-
Source: "installers\win-innosetup\php-win-32\*"; Excludes: "README.md"; DestDir: "{app}\php-32"; Check: (not Is64BitInstallMode) or IsTaskSelected('portablemode'); Flags: createallsubdirs recursesubdirs
172+
Source: "installers\win-innosetup\php-win-32\*"; Excludes: "README.md,*.bak"; DestDir: "{app}\php-32"; Check: (not Is64BitInstallMode) or IsTaskSelected('portablemode'); Flags: createallsubdirs recursesubdirs
171173
#endif
172174
#ifdef PHP_64
173-
Source: "installers\win-innosetup\php-win-64\*"; Excludes: "README.md"; DestDir: "{app}\php-64"; Check: Is64BitInstallMode or IsTaskSelected('portablemode'); Flags: createallsubdirs recursesubdirs
175+
Source: "installers\win-innosetup\php-win-64\*"; Excludes: "README.md,*.bak"; DestDir: "{app}\php-64"; Check: Is64BitInstallMode or IsTaskSelected('portablemode'); Flags: createallsubdirs recursesubdirs
174176
#endif
175177
#ifdef PortableAppMode
176178
Source: "installers\win-innosetup\start.bat"; DestDir: "{app}"; Check: IsTaskSelected('portablemode')

support/pas_functions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ function PAS_StartServer($options)
163163
"dir" => $rootpath
164164
);
165165

166+
// Allow the Windows installer to detect that the software is still running.
167+
if ($windows)
168+
{
169+
$options2["createprocess_exe_opts"] = "/f=SW_HIDE /f=DETACHED_PROCESS";
170+
171+
$winmutex = array();
172+
if (isset($options["business"]) && is_string($options["business"])) $winmutex[] = $options["business"];
173+
if (isset($options["appname"]) && is_string($options["appname"])) $winmutex[] = $options["appname"];
174+
175+
if (count($winmutex)) $options2["createprocess_exe_opts"] .= " " . escapeshellarg("/mutex=" . str_replace(",", "_", implode("_", $winmutex)));
176+
}
177+
166178
$result = ProcessHelper::StartProcess($cmd, $options2);
167179
//var_dump($result);
168180
if (!$result["success"])

0 commit comments

Comments
 (0)