这个程序的进程名已知,并且已经获取了该进程的主窗口句柄,在该进程的界面上进行了几个操作后,会有一个成功的提示,应该是MessageBox一类的模态对话框,我现在想获取这个窗口的句柄,如何来做?

解决方案 »

  1.   

    1.如果能知道弹出窗口的标题或类名,可用FindWindow
    2.试试用hook
      

  2.   

    不能用FindWindow,因为窗口的标题不确定。HOOK具体如何来做?
      

  3.   

    该模态对话框应该是当前活动窗口,用GetActiveWindow()试试。
      

  4.   


    GetActiveWindow怎么确定获取的就是我想要获取的这个程序的窗口句柄呢?
      

  5.   

    我也不知道,调试时弹出这个对话框后,我用GetTopWindow(hParent),取到的结果与我用spy++查看到的结果不一样。
      

  6.   

    CWnd* GetTopWindow( ) const; Return Value
    Identifies the top-level child window in a CWnd linked list of child windows. If no child windows exist, the value is NULL. Res
    If CWnd has no children, this function returns NULL.
    GetTopWindow()只能获得子窗口而已,MESSAGEBOX应该不行吧
      

  7.   

    呵呵,GetLastActivePopup是楼主验证过的,正确的吗?学习了