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
- Fix export of pattern recipe.
- 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!
#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;