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);

 

 

 

 

posted @ 2023-03-10 09:10  天子骄龙  阅读(179)  评论(0编辑  收藏  举报