Portál AbcLinuxu, 9. května 2025 23:36
[Code]
////////// zaciatok psvince.dll //////////
const
ProgramName = 'notepad';
ProgramExeName = 'notepad.exe';
ProgramRunningOnInstallMessage = ProgramName + ' is currently running. ' + #13 + #13 + 'Please close it and then click on ''Retry'' to proceed with the installation.';
InstallationCanceledMessage = 'The installation was canceled.';
ProgramRunningOnUninstallMessage = ProgramName + ' is currently running. ' + #13 + #13 + 'Please close it and then click on ''Retry'' to proceed.';
UninstallationCanceledMessage = 'The uninstallation process was canceled.';
// IsModuleLoadedI - function to call at install time
// Also added setuponly flag
function IsModuleLoadedI(modulename: AnsiString ): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall setuponly';
// IsModuleLoadedU - function to call at uninstall time
// Also added uninstallonly flag
function IsModuleLoadedU(modulename: AnsiString ): Boolean;
external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly' ;
function IsModuleLoaded( modulename: String; isUninstallation: Boolean ): Boolean;
begin
if isUninstallation then
Result := IsModuleLoadedU( modulename )
else
Result := IsModuleLoadedI( modulename );
end;
//------------------------------------------------------------------------------
// Prompt the user to close a program that's still running.
// Finish when the executable is closed or the user cancels the process.
// -> message : A message to show the user to prompt them to close
// -> isUninstallation : Whether this is an uninstallation (to call the right function.)
// <- True if the program was closed (or was not running),
// False if the user clicked on the Cancel button and didn't close the program
function PromptUntilProgramClosedOrInstallationCanceled(message: String; isUninstallation: Boolean ): Boolean;
var
ButtonPressed : Integer;
begin
ButtonPressed := IDRETRY;
// Check if the program is running or if the user has pressed the cancel button
while IsModuleLoaded( ProgramExeName, isUninstallation ) and ( ButtonPressed <> IDCANCEL ) do
begin
ButtonPressed := MsgBox( message , mbError, MB_RETRYCANCEL );
end;
// Has the program been closed?
Result := Not IsModuleLoaded( ProgramExeName, isUninstallation );
end;
//------------------------------------------------------------------------------
function InitializeSetup(): Boolean;
begin
Result := PromptUntilProgramClosedOrInstallationCanceled( ProgramRunningOnInstallMessage, False );
if Not Result then
begin
MsgBox( InstallationCanceledMessage, mbInformation, MB_OK );
end;
end;
//------------------------------------------------------------------------------
function InitializeUninstall(): Boolean;
begin
Result := PromptUntilProgramClosedOrInstallationCanceled( ProgramRunningOnUninstallMessage, True );
// Unload the DLL, otherwise the dll psvince is not deleted
UnloadDLL(ExpandConstant('{app}\psvince.dll'));
if not Result then
begin
MsgBox( UninstallationCanceledMessage, mbInformation, MB_OK );
end;
end;
////////// koniec psvince.dll //////////
teraz by som potreboval, aby premenné ProgramRunningOnInstallMessage, InstallationCanceledMessage sa naplnili textom jazykovej mutácie, ktorú si užívateľ vybral, t.j. povedzme stringom UninstallAppRunningError z slovak.isl (jazyky mám v inno scripte nadefinované). ako mám pozmeniť v kóde vyššie tú časť :???
const
ProgramRunningOnInstallMessage = ProgramName + ' is currently running. ' + #13 + #13 + 'Please close it and then click on ''Retry'' to proceed with the installation.';
prosím o názorný príklad, lebo pascal vôbec neovládam
Řešení dotazu:
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.