zoukankan      html  css  js  c++  java
  • C#使用系统的“显示桌面”功能(Shell.Application)

    在 Windows 系统的 任务栏 上的 快速启动栏 里,通常有一个图标   ,点击这个图标,就会切换到桌面。这个图标实际是一个 “Windows Explorer Command” ,用记事本打开这个文件,我们看到如下的内容:

    [Shell]
    Command=2
    IconFile=explorer.exe,3
    [Taskbar]
    Command=ToggleDesktop

    这个文件的格式,实际是一个 ini 文件的形式,其中,我们要关注的是 Command=ToggleDesktop 这句,这句是explorer要执行的命令;通过 MSDN 我们可以看到关于 ToggleDesktop 的说明:

    This method has the same effect as the Show Desktop button in the Quick Launch area of the Taskbar.  
    It either hides all open windows and shows the desktop, or it hides the desktop and shows all open windows.  
    The ToggleDesktop method does not display any user interface, it just invokes the toggle action.

    在C#中,使用 显示桌面 的功能,实际就是使用 Shell.Application 去执行 ToggleDesktop 这个功能,代码如下:

    Type shellType = Type.GetTypeFromProgID("Shell.Application");
    object shellObject = System.Activator.CreateInstance(shellType);
    shellType.InvokeMember("ToggleDesktop", System.Reflection.BindingFlags.InvokeMethod, 
        null, shellObject, null);

    http://www.cnblogs.com/conkis/

  • 相关阅读:
    The AndroidManifest.xml File
    handlebars简单用法
    高性能跨语言模板引擎Crox
    C++17 新特性
    C++ 14新特性
    [lua]笔记
    [lua]笔记
    delphi关键字
    delphi 基础
    TCP/UDP
  • 原文地址:https://www.cnblogs.com/conkis/p/3114091.html
Copyright © 2011-2022 走看看