Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FindProcess(const ExeFile: string): string;
- const TH32CS_SNAPPROCESS = $00000002;
- var SH: THandle;
- TP: TProcessEntry32;
- PID: DWORD;
- I: Integer;
- S: string;
- begin Result := '';
- if ExeFile = '' then Exit;
- SH := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if Integer(SH) < 0 then Exit;
- TP.dwSize := SizeOf(TProcessEntry32);
- if not Process32First(SH, TP) then Exit;
- PID := 0;
- for I := 0 to 999 do
- begin
- S := UpperCase(TP.szExeFile);
- if SameText(ExeFile, S) then
- begin
- PID := TP.th32ProcessID;
- Break;
- end;
- if not Process32Next(SH, TP) then Break;
- end;
- if PID = 0 then Exit;
- Result := S;
- end;
- // Coded by Appo //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement