本文介绍了最小化文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用最小化的窗口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.

这篇关于最小化文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!