我想获取“ Windows资源管理器” Windows(不是Internet Explorer)的句柄。
通常它与
var processes = Process.GetProcesses();
foreach (var process in processes)
{
var handle = process.Handle;
}
Run Code Online (Sandbox Code Playgroud)
我想做的是以下几点:
将特定的资源管理器窗口移至ForeGround。我已经实现了“ ToForeGround”方法,它对于除Windows资源管理器以外的所有其他Windows都可以正常工作
但是,使用Windows资源管理器时,无论打开多少Windows,我都只能获得任务栏的进程,因此只有一个“ Windows资源管理器”进程。
还是可以向我解释为什么“ Windows资源管理器”与其他程序不同?
观点不错,所以让我尝试简要地解释一下代码的作用-您可以在此处阅读更多有关ShellWindows对象的信息。下面的代码可帮助您找到Windows Explorer的所有正在运行的实例(不是Internet Explorer,请注意,if语句中使用了“ explorer”,而不是“ iexplore”)。
在Windows / system32文件夹中添加对Shell32.dll的引用
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
string filename;
ArrayList windows = new ArrayList();
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("explorer"))
{
//do something with the handle here
MessageBox.Show(ie.HWND.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3954 次 |
| 最近记录: |