Registriert seit: 18. Aug 2004
Ort: Edewecht
712 Beiträge
Delphi 5 Professional
|
Re: ProcessName -> processId
3. Apr 2005, 20:10
Delphi-Quellcode:
function ProcToID(sProcName: String): Integer;
var
hProcSnap: THandle;
pe32: TProcessEntry32;
S: String;
begin
Result := -1;
hProcSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if hProcSnap <> INVALID_HANDLE_VALUE then
begin
if Process32First(hProcSnap, pe32) then
begin
repeat
if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
S := ExtractFileName(pe32.szExeFile)
else
S := pe32.szExeFile;
if SameText(S, sProcName) then
begin
Result := pe32.th32ProcessID;
Break;
end;
until (not Process32Next(hProcSnap, pe32));
end;
CloseHandle(hProcSnap);
end;
end
Ciao, Sprint.
"I don't know what I am doing, but I am sure I am having fun!"
|