且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取Windows资源管理器的进程句柄

更新时间:2023-02-04 15:14:49

点以及采取的,所以让我尽量简明扼要地解释代码不? - 你可以阅读更多关于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()); 
            }
        }