Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

SHVtYW4=


Сообщения: 3451
Благодарности: 1273

Профиль | Отправить PM | Цитировать


saurn,
Ошибочка:
Код: Выделить весь код
procedure TimerProc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD);
begin
    WizardForm.NextButton.Enabled := not IsProcessRunning('calc.exe');
end;
Код: Выделить весь код
procedure TimerProc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD);
begin
    WizardForm.NextButton.Enabled := not IsProcessRunning(''WorldOfTanks.exe');
end;
лучше тогда так:
Код: Выделить весь код
#define KillExe "WorldOfTanks.exe"

[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('{#KillExe}');
end;


procedure InitializeWizard();
begin
    msgPage := CreateOutputMsgPage(wpSelectComponents, 'Заголовок', 'Подзаголовок', 'Сообщение');
end;


function ShouldSkipPage(PageID: Integer): Boolean;
begin
    case PageFromID(PageID) of
        msgPage: Result := not IsProcessRunning('{#KillExe}');
    end;
end;


procedure CurPageChanged(CurPageID: Integer);
begin
    KillTimer(WizardForm.Handle, TIMER_ID);

    case PageFromID(CurPageID) of
        msgPage: if IsProcessRunning('{#KillExe}') then SetTimer(WizardForm.Handle, TIMER_ID, 30, CallbackAddr('TimerProc'));
    end;
end;


procedure DeinitializeSetup();
begin
    KillTimer(WizardForm.Handle, TIMER_ID);
end;
Это сообщение посчитали полезным следующие участники:

Отправлено: 19:06, 27-01-2014 | #2003