uses TLHelp32;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> FSnapshotHandle:THandle;<br> FProcessEntry32:TProcessEntry32;<br> Ret : BOOL;<br> ProcessID : integer;<br> s:string;<br>begin<br> FSnapshotHandle:=CreateToolhelp32Snapshot(<br>TH32CS_SNAPPROCESS,0);<br> //创建系统快照<br> FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);<br> //先初始化 FProcessEntry32 的大小<br> Ret:=Process32First(FSnapshotHandle,FProcessEntry32);<br> while Ret do<br> begin<br> s:=ExtractFileName(FProcessEntry32.szExeFile);<br> if s='KERNEL32.DLL' then<br> begin<br> ProcessID:=FProcessEntry32.th32ProcessID;<br> s:='';<br> break;<br> end;<br> Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);<br> end;<br> //循环枚举出系统开启的所有进程,找出“Kernel32.dll”<br> CloseHandle(FSnapshotHandle);<br> Edit1.Text := 'Process ID '+IntToHex(<br> FProcessEntry32.th32ProcessID,8);<br>end;