能够取得运行的应用程序的CWnd,怎么得到它的进程ID呢?
或者反过来,知道进程ID,如何取得CWnd呢?当然这个进程ID是有窗口的
如果没有能判断吗???谢谢指教!!!!

解决方案 »

  1.   

    GetWindowThreadProcessId
    The GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window. DWORD GetWindowThreadProcessId(
      HWND hWnd,             // handle to window
      LPDWORD lpdwProcessId  // process identifier
    );
    Parameters
    hWnd 
    [in] Handle to the window. 
    lpdwProcessId 
    [out] Pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not. 
    Return Values
    The return value is the identifier of the thread that created the window. 
      

  2.   

    你只要
    DWORD PID, TID;
    TID = ::GetWindowThreadProcessId (pWnd->m_hwnd, &PID);
    就行了
      

  3.   

    大家仔细研究一下我的问题好吗?我知道的是CWnd,
    GetWindowThreadProcessId 这个函数不可以吧,
    zhouyong0371你的语句不能通过编译 阿???
      

  4.   

    To:jxyhelen1(文武贝)DWORD PID, TID;
    TID = ::GetWindowThreadProcessId (pWnd->m_hwnd, &PID);绝对可行的,你把pWnd改为this、把m_hwnd 改为m_hWnd 试一下。