可以自己看看这个例子:<br><br>uses TLHelp32;<br>function GetAppName(const AWindowHandle: THandle): string;<br>var<br> PI: DWORD;<br> ContinueLoop:BOOL;<br> SnapshotHandle:THandle;<br> ProcessEntry32:TProcessEntry32;<br>begin<br> Result := '';<br> GetWindowThreadProcessId(AWindowHandle, @PI);<br><br> SnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br> ProcessEntry32.dwSize := Sizeof(ProcessEntry32);<br> ContinueLoop := Process32First(SnapshotHandle,ProcessEntry32);<br> while ContinueLoop do<br> begin<br> if ProcessEntry32.th32ProcessID = PI then<br> begin<br> Result := ProcessEntry32.szExeFile;<br> break;<br> end;<br> ContinueLoop:=Process32Next(SnapshotHandle, ProcessEntry32);<br> end;<br> CloseHandle(SnapshotHandle);<br>end;<br><br>