【问题标题】:c++ ShellExecute "open" in already opened windowc ++ ShellExecute在已经打开的窗口中“打开”
【发布时间】:2013-07-29 13:15:46
【问题描述】:
I'm trying to open a new folder in the same window that is already opened. This is the code:

if (DirectoryExists(myfolder)) {
    HWND currenthwnd,hwnd;

    hwnd=NULL;
    currenthwnd=GetForegroundWindow();
        if (currenthwnd!=hwnd)
        {
        hwnd=currenthwnd;
            if (hwnd!=NULL) 
                {
                ShellExecute(hwnd, "open", myfolder, NULL, NULL, SW_SHOW);
                }
        }
}

但它每次都会打开一个新窗口。我怎样才能做到这一点?

【问题讨论】:

    标签: c++ shellexecute hwnd


    【解决方案1】:

    您传递的hwnd 窗口。通常,您也无法获得随机窗口来执行您想要的任何操作。你给他们发信息,如果他们理解信息,他们就会做出反应。例如。 WM_CLOSE 几乎总是被理解,WM_COPYDATA 较少被理解。

    在这种情况下,它有点复杂。您需要通过IShellWindows 找到shell 窗口。然后设法调用它的IExplorerBrowser::BrowseToObject 方法。但这有点太复杂了,无法在这里解释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多