• Declare nas uses:

Código PHP:
TlHelp32 
Código PHP:
function GetPID(ProcessName: string): DWORD; //Função obter o ID do Processo (PID)
var MyHandle: THandle;
Struct: TProcessEntry32;
begin
Result
:=0;
try
MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROC ESS, 0);
Struct.dwSize:=Sizeof(TProcessEntry32);
if 
Process32First(MyHandle, Struct) then
if Struct.szExeFile=ProcessName then
begin
Result
:=Struct.th32ProcessID;
Exit;
end;
while 
Process32Next(MyHandle, Struct) do
if 
Struct.szExeFile=ProcessName then
begin
Result
:=Struct.th32ProcessID;
Exit;
end;
except on exception do
Exit; 
end;
end; 
  • Para utilizar

Código PHP:
PID:= GetPID('main.exe'); 
Barbada, resto é com vocês.