这是通过窗体的句柄得到程序名的代码,但是只在9X底下有用,NT不行。<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>