就用GetWindowThreadProcessId,这个函数是获取指定窗口的线程ID和进程IDHWND hWnd; // 窗口的句柄DWORD dwPID;DWORD dwThreadID = ::GetWindowThreadProcessId(hWnd, &dwPID);执行成功后,dwPID便是获取到的进程ID