MFC-GetWindowThreadProcessId获取指定窗口线程ID和进程ID
HWND hWnd = ::FindWindow(NULL, _T("sss.txt - 记事本")); DWORD dwTID=0; DWORD dwPID = NULL; dwTID = ::GetWindowThreadProcessId(hWnd, &dwPID);//获取指定窗口线程ID和进程ID //参数1:窗口句柄HWND //参数2:LPDWORD 保存进程ID //返回值:线程ID CString str; str.Format(_T("%d"), dwPID); AfxMessageBox(str);