用 ShellExecute 打开一个对话框程序, 并且把当前窗体的句柄作为参数传入, 在该对话框如何获取父窗体的句柄?当我用 GetParent()->m_hWnd 获取句柄的时候总是为0.

解决方案 »

  1.   


    BOOL CreateProcess(
      LPCTSTR lpApplicationName,                 // name of executable module
      LPTSTR lpCommandLine,                      // command line string
      LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
      LPSECURITY_ATTRIBUTES lpThreadAttributes,  // SD
      BOOL bInheritHandles,                      // handle inheritance option
      DWORD dwCreationFlags,                     // creation flags
      LPVOID lpEnvironment,                      // new environment block
      LPCTSTR lpCurrentDirectory,                // current directory name
      LPSTARTUPINFO lpStartupInfo,               // startup information
      LPPROCESS_INFORMATION lpProcessInformation // process information
    );创建进程,把父进程的窗口句柄作为LPTSTR lpCommandLine传进去,子进程用
    GetCommandLine获得
      

  2.   

    这样不可以的!要得到句柄,要么FindWindow(),要么用CreateProcess.
    前者方便,简单;但是后者麻烦,但是功能很强
      

  3.   

    自定义广播消息。RegisterWindowMessage + BroadcastSystemMessage
      

  4.   

    ShellExecute 启动的是一个进程,没有父子关系。
    用FindWindow(),
    消息则用SendMessage