Added code to inno setup control file to check if OpenLP is running and user attempts an uninstall.

A message is displayed and uninstall waits until OpenLP is closed or the uninstall is canceled.

bzr-revno: 1782
Fixes: https://launchpad.net/bugs/871522
This commit is contained in:
Stevan Pettit 2011-10-21 06:57:47 +01:00 committed by Tim Bentley
commit 79f47e2d23

View File

@ -65,8 +65,11 @@ Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription
[Files] [Files]
Source: ..\..\dist\OpenLP\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs Source: ..\..\dist\OpenLP\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
Source: psvince.dll; Flags: dontcopy ; DLL used to check if the target program is running at install time
; NOTE: Don't use "Flags: ignoreversion" on any shared system files Source: psvince.dll; flags: dontcopy
; psvince is installed in {app} folder, so it will be loaded at
; uninstall time to check if the target program is running
Source: psvince.dll; DestDir: {app}
[Icons] [Icons]
Name: {group}\{#AppName}; Filename: {app}\{#AppExeName} Name: {group}\{#AppName}; Filename: {app}\{#AppExeName}
@ -87,8 +90,13 @@ Root: HKCR; Subkey: "OpenLP\DefaultIcon"; ValueType: string; ValueName: ""; Valu
Root: HKCR; Subkey: "OpenLP\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\OpenLP.exe"" ""%1""" Root: HKCR; Subkey: "OpenLP\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\OpenLP.exe"" ""%1"""
[Code] [Code]
function IsModuleLoaded(modulename: AnsiString ): Boolean; // Function to call psvince.dll at install time
external 'IsModuleLoaded@files:psvince.dll stdcall'; function IsModuleLoadedInstall(modulename: AnsiString ): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall setuponly';
// Function to call psvince.dll at uninstall time
function IsModuleLoadedUninstall(modulename: AnsiString ): Boolean;
external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly' ;
function GetUninstallString(): String; function GetUninstallString(): String;
var var
@ -133,7 +141,7 @@ end;
function InitializeSetup(): Boolean; function InitializeSetup(): Boolean;
begin begin
Result := true; Result := true;
while IsModuleLoaded( 'OpenLP.exe' ) and Result do while IsModuleLoadedInstall( 'OpenLP.exe' ) and Result do
begin begin
if MsgBox( 'Openlp is currently running, please close it to continue the install.', if MsgBox( 'Openlp is currently running, please close it to continue the install.',
mbError, MB_OKCANCEL ) = IDCANCEL then mbError, MB_OKCANCEL ) = IDCANCEL then
@ -153,3 +161,16 @@ begin
end; end;
end; end;
end; end;
function InitializeUninstall(): Boolean;
begin
Result := true;
while IsModuleLoadedUninstall( 'OpenLP.exe' ) and Result do
begin
if MsgBox( 'Openlp is currently running, please close it to continue the uninstall.',
mbError, MB_OKCANCEL ) = IDCANCEL then
begin
Result := false;
end;
end;
end;