求救!获取线程ID的问题
今天遇到一个问题,就是我想获得线程ID,但是GetWindowThreadProcessId()的第二个参数我该怎么写?我写null但是有错误,谢谢解答!
[解决办法]
refer:
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
static void Main(string[] args)
{
IntPtr hwnd = FindWindow(null, "计算器");
if (hwnd != IntPtr.Zero)
{
int calcID;
//获取进程ID
GetWindowThreadProcessId(hwnd, out calcID);
}
}