![]() |
|
#1
|
|||
|
|||
![]() Надо соеденить 2 юнита
Принцип такой.В первый юнит ищет процесс,когда процесс запущен должен открываться второй юнит.А второй юнит должен ждать команду от первого юнита(тоесть не запускаться сразу а ждать) Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, tlhelp32, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; showed:boolean=false; implementation {$R *.dfm} function processExists(exeFileName: string): Boolean; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32); Result := False; while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then begin Result := True; end; ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end; procedure TForm1.FormCreate(Sender: TObject); begin Application.ShowMainForm := False; end; procedure TForm1.Timer1Timer(Sender: TObject); begin if processExists('game.exe') then begin if not(showed) then begin showed:=true; ShowMessage('Процесс запущен'); end; end else if showed then showed:=false; end; end. |