最小化文件夹最小化、文件夹

由网友(久违的故事)分享简介:我想用最小化的窗口C#I want to minimize a window using C#例如:我已经开了这条路 E:\ 用Ex : I have opened this path E:\ using process.start(E:\)和我希望尽量减少对某个事件的这条道路。And I want to m...

我想用最小化的窗口C#

I want to minimize a window using C#

例如:我已经开了这条路 E:

Ex : I have opened this path E: using

process.start(E:)

和我希望尽量减少对某个事件的这条道路。

And I want to minimize this path on a certain event.

我怎样才能做到这一点?

How can I make that possible?

推荐答案

下面的示例控制台应用程序code将尽量减少打开关于电子商务的所有外壳浏览器访问量::

The following sample Console Application code will minimize all shell explorer views that are opened on E: :

class Program
{
    static void Main(string[] args)
    {
        // add a reference to "Microsoft Shell Controls and Automation" COM component
        // also add a 'using Shell32;'
        Shell shell = new Shell();
        dynamic windows = shell.Windows(); // this is a ShellWindows object
        foreach (dynamic window in windows)
        {
            // window is an WebBrowser object
            Uri uri = new Uri((string)window.LocationURL);
            if (uri.LocalPath == @"E:")
            {
                IntPtr hwnd = (IntPtr)window.HWND; // WebBrowser is also an IWebBrowser2 object
                MinimizeWindow(hwnd);
            }
        }
    }

    static void MinimizeWindow(IntPtr handle)
    {
        const int SW_MINIMIZE = 6;
        ShowWindow(handle, SW_MINIMIZE);
    }

    [DllImport("user32.dll")]
    private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}

它使用的脚本的壳对象。注意动态关键字是强制性这里的用法,因为没有凉类型库,因此没有任何智能感知

It's using the Shell Objects for Scripting. Note the usage of the dynamic keyword that's mandatory here because there is no cool typelib, and therefore no intellisense either.

阅读全文

相关推荐

最新文章