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/

  • 相关阅读:
    LeetCode-6 ZigZag Conversion
    求两个字符串的最长公共子串
    Eclipse 添加 javap
    时间复杂度
    leetcode oj-3
    Android Rom分区 与 SD卡读写
    论文首次处理流程及代码
    论文片段
    项目整体流程
    春晚项目中的相关脚本
  • 原文地址:https://www.cnblogs.com/conkis/p/3114091.html
Copyright © 2011-2022 走看看