Improve Windows installer. Avoid crashing on checking if a program is still running.

This commit is contained in:
Roman Telezhynskyi 2021-01-27 15:10:06 +02:00
parent 1019f91d5b
commit e714999430
2 changed files with 27 additions and 11 deletions

View File

@ -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 # Version 0.7.42 Jan 26, 2021
- Fix export of pattern recipe. - Fix export of pattern recipe.
- Update translations. - Update translations.

View File

@ -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! ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Valentina" #define MyAppName "Valentina"
#define MyAppVersion GetFileVersion('valentina\valentina.exe') #define MyAppVersion GetFileVersion('valentina\valentina.exe')
#define MyAppPublisher "Roman Telezhynskyi" #define MyAppPublisher "Roman Telezhynskyi"
#define MyAppURL "http://valentinaproject.bitbucket.io/" #define MyAppURL "https://valentinaproject.bitbucket.io/"
#define MyAppExeName "valentina.exe" #define MyAppExeName "valentina.exe"
#define MyAppCopyright "(C) 2013-2020 Valentina project" #define MyAppCopyright "(C) 2013-2020 Valentina project"
#define MyDateTimeString GetDateTimeString('yyyymmddhhnnss', '', ''); #define MyDateTimeString GetDateTimeString('yyyymmddhhnnss', '', '');
@ -30,7 +30,7 @@ DefaultGroupName={#MyAppName}
LicenseFile=.\LICENSE_VALENTINA LicenseFile=.\LICENSE_VALENTINA
InfoAfterFile=.\valentina\README.txt InfoAfterFile=.\valentina\README.txt
OutputDir=.\ OutputDir=.\
OutputBaseFilename=valentina_{#MyAppVersion}{#MyAppStatus}-{#MyDateTimeString} OutputBaseFilename=valentina_{#MyAppVersion}{#MyAppStatus}_i386
SetupIconFile=.\valentina\valentina.ico SetupIconFile=.\valentina\valentina.ico
UninstallDisplayIcon={app}\valentina.ico UninstallDisplayIcon={app}\valentina.ico
Compression=lzma Compression=lzma
@ -358,6 +358,12 @@ russian.QuestionRemoveAnyExistingSettings = Вы хотите удалить с
ukrainian.QuestionRemoveAnyExistingSettings = Видалити будь-які існуючі налаштування? ukrainian.QuestionRemoveAnyExistingSettings = Видалити будь-які існуючі налаштування?
german.QuestionRemoveAnyExistingSettings = Möchten Sie vorhandene Einstellungen entfernen? 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] [Code]
const const
@ -399,15 +405,22 @@ var
WMIService: Variant; WMIService: Variant;
WbemLocator: Variant; WbemLocator: Variant;
WbemObjectSet: Variant; WbemObjectSet: Variant;
InstallationFindAppMessage: String;
begin begin
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); try
WMIService := WbemLocator.ConnectServer('localhost', 'root\CIMV2'); WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemObjectSet := WMIService.ExecQuery('SELECT * FROM Win32_Process Where Name="' + AppName + '"'); WMIService := WbemLocator.ConnectServer('localhost', 'root\CIMV2');
if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then WbemObjectSet := WMIService.ExecQuery('SELECT * FROM Win32_Process Where Name="' + AppName + '"');
begin if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
Result := True; begin
end Result := True;
else begin end
else begin
Result := False;
end;
except
InstallationFindAppMessage := ExpandConstant('{cm:ErrorFindApp}');
MsgBox( InstallationFindAppMessage, mbError, MB_OK );
Result := False; Result := False;
end; end;
end; end;