Ветеран
Сообщения: 517
Благодарности: 314
Профиль
|
Отправить PM
| Цитировать
innot20 ,
читать дальше »
Код:
[Setup]
AppName =My Program
AppVerName =My Program v 1.5
DefaultDirName ={pf} \My Program
OutputDir =.
[ code]
const
TH32CS_SNAPPROCESS = $2;
INVALID_HANDLE_VALUE = -1;
TIMER_ID = 01;
type
TPROCESSENTRY32 = record
dwSize, cntUsage, th32ProcessID: DWORD;
th32DefaultHeapID: Longint;
th32ModuleID, cntThreads, th32ParentProcessID: DWORD;
pcPriClassBase: Longint;
dwFlags: DWORD;
szExeFile: array [ 0..259] of char;
end ;
TFNTimerProc = Longint;
function CreateToolhelp32Snapshot(dwFlags, th32ProcessID: DWORD): THandle; external 'CreateToolhelp32Snapshot@kernel32.dll stdcall';
function Process32First(hSnapshot: THandle; var lppe: TPROCESSENTRY32): Boolean; external 'Process32First@kernel32.dll stdcall';
function Process32Next(hSnapshot: THandle; var lppe: TPROCESSENTRY32): Boolean; external 'Process32Next@kernel32.dll stdcall';
function CloseHandle(hObject: THandle): Boolean; external 'CloseHandle@kernel32.dll stdcall';
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT; lpTimerFunc: TFNTimerProc): UINT; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL; external 'KillTimer@user32.dll stdcall';
var
msgPage: TOutputMsgWizardPage;
function IsProcessRunning(FileName: String ): Boolean;
var
hProcessSnap: THandle;
pe32: TPROCESSENTRY32;
szExeFile: String ;
begin
hProcessSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if hProcessSnap = INVALID_HANDLE_VALUE then Exit;
pe32.dwSize := sizeof(pe32);
if not Process32First(hProcessSnap, pe32) then Exit;
while not Result and Process32Next(hProcessSnap, pe32) do
begin
szExeFile := '';
while not (pe32.szExeFile[ Length(szExeFile)] = #0) do szExeFile := szExeFile + pe32.szExeFile[ Length(szExeFile)];
Result := LowerCase(FileName) = LowerCase(szExeFile);
end ;
CloseHandle(hProcessSnap);
end ;
procedure TimerProc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD);
begin
WizardForm.NextButton.Enabled := not IsProcessRunning('WorldOfTanks.exe');
end ;
procedure InitializeWizard ();
begin
msgPage := CreateOutputMsgPage(wpSelectComponents, 'Заголовок', 'Подзаголовок', 'Сообщение');
end ;
function ShouldSkipPage (PageID: Integer): Boolean;
begin
case PageFromID(PageID) of
msgPage: Result := not IsProcessRunning('WorldOfTanks.exe');
end ;
end ;
procedure CurPageChanged (CurPageID: Integer);
begin
KillTimer(WizardForm.Handle, TIMER_ID);
case PageFromID(CurPageID) of
msgPage: if IsProcessRunning('WorldOfTanks.exe') then SetTimer(WizardForm.Handle, TIMER_ID, 30, CallbackAddr('TimerProc'));
end ;
end ;
procedure DeinitializeSetup ();
begin
KillTimer(WizardForm.Handle, TIMER_ID);
end ;
И еще:
читать дальше »
Код:
[Setup]
AppName =My Program
AppVerName =My Program v 1.5
DefaultDirName ={pf} \My Program
OutputDir =.
[ code]
const
TH32CS_SNAPPROCESS = $2;
INVALID_HANDLE_VALUE = -1;
type
TPROCESSENTRY32 = record
dwSize, cntUsage, th32ProcessID: DWORD;
th32DefaultHeapID: Longint;
th32ModuleID, cntThreads, th32ParentProcessID: DWORD;
pcPriClassBase: Longint;
dwFlags: DWORD;
szExeFile: array [ 0..259] of char;
end ;
function CreateToolhelp32Snapshot(dwFlags, th32ProcessID: DWORD): THandle; external 'CreateToolhelp32Snapshot@kernel32.dll stdcall';
function Process32First(hSnapshot: THandle; var lppe: TPROCESSENTRY32): Boolean; external 'Process32First@kernel32.dll stdcall';
function Process32Next(hSnapshot: THandle; var lppe: TPROCESSENTRY32): Boolean; external 'Process32Next@kernel32.dll stdcall';
function CloseHandle(hObject: THandle): Boolean; external 'CloseHandle@kernel32.dll stdcall';
var
msgPage: TOutputMsgWizardPage;
function IsProcessRunning(FileName: String ): Boolean;
var
hProcessSnap: THandle;
pe32: TPROCESSENTRY32;
szExeFile: String ;
begin
hProcessSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if hProcessSnap = INVALID_HANDLE_VALUE then Exit;
pe32.dwSize := sizeof(pe32);
if not Process32First(hProcessSnap, pe32) then Exit;
while not Result and Process32Next(hProcessSnap, pe32) do
begin
szExeFile := '';
while not (pe32.szExeFile[ Length(szExeFile)] = #0) do szExeFile := szExeFile + pe32.szExeFile[ Length(szExeFile)];
Result := LowerCase(FileName) = LowerCase(szExeFile);
end ;
CloseHandle(hProcessSnap);
end ;
function NextButtonClick (CurPageID: Integer): Boolean;
begin
Result := True;
case PageFromID(CurPageID) of
msgPage:
begin
if not IsProcessRunning('WorldOfTanks.exe') then Result := True
else begin
MsgBox('Программа все еще запущена', mbError, MB_OK);
Result := False;
end ;
end ;
end ;
end ;
procedure InitializeWizard ();
begin
msgPage := CreateOutputMsgPage(wpSelectComponents, 'Заголовок', 'Подзаголовок', 'Сообщение');
end ;
function ShouldSkipPage (PageID: Integer): Boolean;
begin
case PageFromID(PageID) of
msgPage: Result := not IsProcessRunning('WorldOfTanks.exe');
end ;
end ;
Последний раз редактировалось saurn, 27-01-2014 в 19:19 .
Это сообщение посчитали полезным следующие участники:
Отправлено : 18:39, 27-01-2014
| #2001