2

我希望能够更改现有资源管理器窗口的目录。是否有 api 调用向窗口发送“导航到那里”消息(可能带有句柄)?

4

1 回答 1

1

首先,添加对 Microsoft Internet 控件库的引用。然后您可以使用以下代码,假设您已经知道资源管理器窗口的窗口句柄:

var shellWindows = new SHDocVw.ShellWindows();
var myFolder = "C:\\temp"; // folder name you want to navigate to
var myHwnd = 0; // whatever window handle you're looking for
foreach (SHDocVw.InternetExplorer shellWindow in shellWindows)
{
    if (shellWindow.HWND == myHwnd)
    {
        shellWindow.Navigate(myFolder);
        break;
    }
}
于 2013-04-17T20:59:23.210 回答