簡體   English   中英

c ++ ShellExecute在已打開的窗口中“打開”

[英]c++ ShellExecute “open” in already opened window

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

但這每次都會打開一個新窗口。 我該如何實現?

您傳遞的hwnd窗口。 通常,您無法讓隨機窗口也執行您想要的任何操作。 您向他們發送了一條消息,如果他們了解該消息,他們將對此做出反應。 例如,幾乎總是了解WM_CLOSE ,而很少了解WM_COPYDATA

在這種情況下,它有點復雜。 您需要通過IShellWindows查找shell窗口。 然后設法調用其IExplorerBrowser::BrowseToObject方法。 但這太復雜了,在這里無法解釋。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM