From e71499943047287e60235e0b13d06b28d6e1eca6 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 27 Jan 2021 15:10:06 +0200 Subject: [PATCH] Improve Windows installer. Avoid crashing on checking if a program is still running. --- ChangeLog.txt | 3 +++ dist/win/inno/valentina.iss | 35 ++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index ed58701c0..6e5881241 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,6 @@ +# Version 0.7.43 (unreleased) +- Improve Windows installer. Avoid crashing on checking if a program is still running. + # Version 0.7.42 Jan 26, 2021 - Fix export of pattern recipe. - Update translations. diff --git a/dist/win/inno/valentina.iss b/dist/win/inno/valentina.iss index 053625e54..5bf98371c 100644 --- a/dist/win/inno/valentina.iss +++ b/dist/win/inno/valentina.iss @@ -1,10 +1,10 @@ -; Script generated by the Inno Script Studio Wizard. +; Script generated by the Inno Script Studio Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Valentina" #define MyAppVersion GetFileVersion('valentina\valentina.exe') #define MyAppPublisher "Roman Telezhynskyi" -#define MyAppURL "http://valentinaproject.bitbucket.io/" +#define MyAppURL "https://valentinaproject.bitbucket.io/" #define MyAppExeName "valentina.exe" #define MyAppCopyright "(C) 2013-2020 Valentina project" #define MyDateTimeString GetDateTimeString('yyyymmddhhnnss', '', ''); @@ -30,7 +30,7 @@ DefaultGroupName={#MyAppName} LicenseFile=.\LICENSE_VALENTINA InfoAfterFile=.\valentina\README.txt OutputDir=.\ -OutputBaseFilename=valentina_{#MyAppVersion}{#MyAppStatus}-{#MyDateTimeString} +OutputBaseFilename=valentina_{#MyAppVersion}{#MyAppStatus}_i386 SetupIconFile=.\valentina\valentina.ico UninstallDisplayIcon={app}\valentina.ico Compression=lzma @@ -358,6 +358,12 @@ russian.QuestionRemoveAnyExistingSettings = Вы хотите удалить с ukrainian.QuestionRemoveAnyExistingSettings = Видалити будь-які існуючі налаштування? german.QuestionRemoveAnyExistingSettings = Möchten Sie vorhandene Einstellungen entfernen? +ErrorFindApp = Unable to check if a program is running. Please, close the program before continue and press OK to continue the installation. +english.ErrorFindApp = Unable to check if a program is running. Please, close the program before continue and press OK to continue the installation. +russian.ErrorFindApp = Невозможно проверить, запущена ли программа. Пожалуйста, закройте программу перед продолжением и нажмите OK, чтобы продолжить установку. +ukrainian.ErrorFindApp = Неможливо перевірити, чи запущена програма. Будь ласка, закрийте програму перед продовженням та натисніть OK, щоб продовжити встановлення. +german.ErrorFindApp = Es kann nicht geprüft werden, ob ein Programm läuft. Bitte schließen Sie das Programm, bevor Sie fortfahren, und drücken Sie OK, um die Installation fortzusetzen. + [Code] const @@ -399,15 +405,22 @@ var WMIService: Variant; WbemLocator: Variant; WbemObjectSet: Variant; + InstallationFindAppMessage: String; begin - WbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); - WMIService := WbemLocator.ConnectServer('localhost', 'root\CIMV2'); - WbemObjectSet := WMIService.ExecQuery('SELECT * FROM Win32_Process Where Name="' + AppName + '"'); - if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then - begin - Result := True; - end - else begin + try + WbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); + WMIService := WbemLocator.ConnectServer('localhost', 'root\CIMV2'); + WbemObjectSet := WMIService.ExecQuery('SELECT * FROM Win32_Process Where Name="' + AppName + '"'); + if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then + begin + Result := True; + end + else begin + Result := False; + end; + except + InstallationFindAppMessage := ExpandConstant('{cm:ErrorFindApp}'); + MsgBox( InstallationFindAppMessage, mbError, MB_OK ); Result := False; end; end;