this slowpoke moves

Is exe Running

uses ExtCtrls, TlHelp32

function IsExeRunning(const AExeName: string): boolean;
var
  h: THandle;
  p: TProcessEntry32;
begin
  Result := False;

  p.dwSize := SizeOf(p);
  h := CreateToolHelp32Snapshot(TH32CS_SnapProcess, 0);
  try
    Process32First(h, p);
    repeat
      Result := AnsiUpperCase(AExeName) = AnsiUpperCase(p.szExeFile);
    until Result or (not Process32Next(h, p));
  finally
    CloseHandle(h);
  end;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsExeRunning('Notepad.exe') then
   ShowMessage('Notepad läuft')
	else
   ShowMessage('Notepad läuft nicht');
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate