var
h:thandle;
f:boolean;
lppe:tprocessentry32;
H1: DWORD;
begin
h := CreateToolhelp32Snapshot(TH32cs_SnapProcess, 0);
lppe.dwSize := sizeof(lppe);
f := Process32First(h, lppe);
//lppe.szExeFile是进程的名字,自己挑选你要的
//lppe.th32ProcessID就是你要的进程号
while integer(f) <> 0 do
begin
if lppe.szExeFile = '程序名.exe' then
begin
break;
end;
f := Process32Next(h, lppe);
if integer(f) = 0 then Exit;
end;
H1 := lppe.th32ProcessID;
end;