WinAPI: GetWindowThreadProcessId - 获取指定窗口的进程 ID 或线程 ID
2008-03-10 11:59
525 查看
//声明: GetWindowThreadProcessId( hWnd: HWND; {指定窗口句柄} lpdwProcessId: Pointer = nil {返回进程 ID 的指针} ): DWORD; {返回线程 ID} //举例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var c: Cardinal; begin GetWindowThreadProcessId(Handle, @c); ShowMessage(IntToStr(c)); {2792; 随机的} {在本例中相同于 GetCurrentProcessID 的结果} c := GetCurrentProcessID; ShowMessage(IntToStr(c)); {2792} c := GetWindowThreadProcessId(Handle, nil); ShowMessage(IntToStr(c)); {2748} {在本例中相同于 GetCurrentThreadID 的结果} c := GetCurrentThreadID; ShowMessage(IntToStr(c)); {2748} end; end.
相关文章推荐
- GetWindowThreadProcessId 获得窗口所在进程ID和线程ID
- GetWindowThreadProcessId 获得窗口所在进程ID和线程ID
- Windows API详解——GetWindowThreadProcessId 获得窗口所在进程ID和线程ID
- 假如想自己写软件的话,可以先FindWindow找到那个窗口的句柄,然后用GetWindowThreadProcessId就可以得到这个窗口的进程ID和线程ID,有了这些ID就可以找到进程名称了。
- 从窗口句柄获取进程句柄并终止进程GetWindowThreadProcessID
- 获取其它进程窗口中的状态栏信息(FindWindowEx GetWindowThreadProcessId OpenProcess SendMessage轮番轰炸)
- GetWindowThreadProcessId获得进程、线程ID
- GetParentProcessId获取父进程ID
- WinAPI: GetNextWindow - 获取指定窗口Z上或Z下的窗口的句柄
- WinAPI: GetClassName - 获取指定窗口的类名
- 查看进程所用的内存(使用GetWindowThreadProcessId取得进程ID,OpenProcess打开进程和GetProcessMemoryInfo取得内存信息)
- WinAPI: GetClassName - 获取指定窗口的类名
- 获取指定窗口句柄结束进程 OpenProcess FindWindow GetExitCodeprocess TerminateProcess
- WinAPI: GetClassName - 获取指定窗口的类名
- WinAPI: GetClassName - 获取指定窗口的类名
- WinAPI: GetNextWindow - 获取指定窗口Z上或Z下的窗口的句柄
- WinAPI: GetTopWindow - 获取指定窗口的子窗口中最顶层的窗口句柄
- VC获取进程ID 线程ID 窗口句柄
- 通过进程Id获取窗口句柄
- 获取进程或线程的ID以及句柄信息