Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
Demander la fermeture de Word avant l'installation
Browse files Browse the repository at this point in the history
  • Loading branch information
brrd committed Dec 9, 2016
1 parent 51e50d4 commit 3abda16
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions win_setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ BeveledLabel= {#AppVersion}.{#SetupVersion}
[CustomMessages]
fr.AppName=Modèles pour Revues.org
fr.WordNotFound=Attention! La détection de Microsoft Word a échoué. Souhaitez-vous quand même poursuivre l'installation ?
fr.PleaseCloseWord=Microsoft Word est actuellement en cours d'utilisation. Veuillez quitter tous les processus de Word en cours d'exécution puis cliquer sur OK.
en.AppName=Revues.org Templates
en.WordNotFound=Warning! Detection of Microsoft Word has failed. Do you want to force installation?
en.PleaseCloseWord=Microsoft Word is currently running. Please exit all Microsoft Word processes before continuing.
[Languages]
Name: "fr"; MessagesFile: "compiler:Languages\French.isl"
Expand All @@ -58,6 +60,9 @@ Source: "src\img\revuesorg.ico"; DestDir: "{app}"; Flags: ignoreversion overwrit
; Anciens fichiers à supprimer
Type: files; Name: "{userappdata}\Microsoft\Templates\revuesorg_complet.dot"
[UninstallRun]
Filename: "taskkill"; Parameters: "/im ""winword.exe"""; Flags: runhidden
[Code]
var
Msg: String;
Expand All @@ -67,9 +72,30 @@ begin
Result := DirExists(ExpandConstant('{userappdata}\Microsoft\Templates')) and DirExists(ExpandConstant('{userappdata}\Microsoft\Word\STARTUP'));
end;
function IsAppRunning(const FileName : string): Boolean;
var
FSWbemLocator: Variant;
FWMIService : Variant;
FWbemObjectSet: Variant;
begin
Result := false;
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
end;
function InitializeSetup(): Boolean;
var
AskCloseWord: Boolean;
begin
Log('InitializeSetup called');
// Detection des templates
Result := True;
if WordExists() = False then
begin
Expand All @@ -80,4 +106,19 @@ begin
Result := True;
end;
end;
// Ne pas installer si process winword en cours
if Result then
begin
AskCloseWord := True;
while (IsAppRunning('winword.exe') and AskCloseWord) do
begin
Msg := CustomMessage('PleaseCloseWord');
if MsgBox(Msg, mbConfirmation, MB_OKCANCEL) = IDCANCEL then
begin
AskCloseWord := False;
Result := False;
end;
end;
end;
end;

0 comments on commit 3abda16

Please sign in to comment.