草庐IT

GetWindowThreadProcessId

全部标签

c++ - 枚举窗口时出现问题

我在尝试运行以下代码时遇到问题:#include"header.h"intmain(){id=GetCurrentProcessId();EnumWindows(hEnumWindows,NULL);Sleep(5000);//MoveWindow(hThis,450,450,100,100,TRUE);system("pause");return0;}//header.h#include#include#include#includeusingnamespacestd;DWORDid=0;HWNDhThis=NULL;BOOLCALLBACKhEnumWindows(HWNDhwnd

c - ProcessID困惑

我很困惑。为什么notepad.exe有三个不同的进程ID?1)Spy++说000000A48(嗯?)2)任务管理器说:26323)GetWindowThreadProcessId说:1744我想2632是在SetWindowsHookEx中使用的正确值(作为dwThreadId参数),但是如果GetWindowThreadProcessId返回其他内容,我如何找到正确的值? 最佳答案 一个进程只有一个唯一的进程ID。但是Spy++将值报告为十六进制,而任务管理器将其报告为十进制。现在,A48(十六进制)等于2632(十进制)。另一

c# - 从控制句柄获取进程

我有一个属于系统中另一个进程的控件的句柄。我怎样才能得到它所属的进程?我尝试查找合适的函数,但没有找到太多。 最佳答案 我想您所说的“控件句柄”是指HWND。然后,使用GetWindowThreadProcessIdHWNDhWndToSomeControl;[...]DWORDdwPid;GetWindowThreadProcessId(hWndToSomeControl,&dwPid);编辑:错误控制(在Windows7上测试):HWNDhWndToSomeControl;[...]DWORDdwPid;DWORDdwTid=G

c# - 如何将 IntPtr 转换为 int

窗口句柄有时是int类型,有时是IntPtrint示例:[DllImport("user32.dll")]staticexternuintGetWindowThreadProcessId(inthWnd,intProcessId);IntPtr示例:[DllImport("user32.dll",CharSet=CharSet.Auto)]staticexternIntPtrSendMessage(IntPtrhWnd,uintMsg,intwParam,StringBuilderlParam);我似乎无法从一个转换/转换为另一个。当我尝试this.ProcessID=GetWindo

c# - 如何在 C# 中获取事件进程名称?

如何在C#中获取事件进程名称?我知道我必须使用这段代码:[DllImport("user32.dll")]privatestaticexternIntPtrGetForegroundWindow();但是我不知道怎么用。 最佳答案 如thisanswer中所述,您必须使用GetWindowThreadProcessId()获取窗口的进程ID,然后您可以使用Process:[DllImport("user32.dll")]publicstaticexternIntPtrGetWindowThreadProcessId(IntPtrhW