获取Windows资源管理器的进程句柄 [英] Get Process Handle of Windows Explorer

查看:640
本文介绍了获取Windows资源管理器的进程句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要得到我的Windows资源管理器窗口(不是Internet Explorer)的句柄。

I want to get the Handle of my "Windows Explorer" Windows (not Internet Explorer).

通常情况下它与

var processes = Process.GetProcesses();
foreach (var process in processes)
{
    var handle = process.Handle;
}



我想什么做的是以下内容:

带上一个特定的浏览器窗口,以前景
我已经实现了ToForeGround方法并能正常工作的所有其他窗口,除了Windows资源管理器

Bring the a specific Explorer Window to ForeGround. I have implemented the "ToForeGround" Method and it works fine for all other Windows except the Windows Explorer

但与Windows资源管理器,我只拿到的过程多少的Windows任务栏上的独立是开放的,只有一个Windows资源管理器的过程。

But with the Windows Explorer i only get the Process of the Taskbar independent of how much Windows are open, there is only one "Windows Explorer" Process.

或者有人可以解释我为什么在Windows资源管理器,是有别于其他programms的

Or can somebody explain me why the "Windows Explorer" is different from other Programms?

推荐答案

点以及采取的,所以让我尽量简明扼要地解释代码不? - 你可以阅读更多关于ShellWindows这里对象的http:// MSDN。 microsoft.com/en-us/library/windows/desktop/bb773974(v=vs.85).aspx

Point well taken, so let me try to explain briefly what the code does - you can read more about the ShellWindows object here http://msdn.microsoft.com/en-us/library/windows/desktop/bb773974(v=vs.85).aspx

下面的代码可以帮助你找到所有Windows资源管理器的运行实例(不是Internet Explorer,请注意,资源管理器中使用if语句,而不是IEXPLORE)。

The code below helps you find all running instances of Windows Explorer (not Internet Explorer, note that "explorer" is used in the if statement and not "iexplore").

添加引用的Shell32.dll,位于Windows / system32文件夹下

Add Reference to Shell32.dll, located in the Windows/system32 folder

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

这篇关于获取Windows资源管理器的进程句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆