C # use the system's "show desktop" function (Shell. Application)

Source: Internet
Author: User

On the Windows system taskbarQuick Start barThere is usually an icon. Click this icon to switch to the desktop. This icon is actually a "Windows Explorer command". Open this file in notepad and we can see the following content:

 
Mongoshelldeskcommand%2iconfile%%er.exe, 3 [taskbar] command = toggledesktop

The format of this file is actually an INI file. Here, we need to pay attention to the command = toggledesktop sentence, which is the command to be executed by explorer; with msdn, we can see instructions on 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.

 

In C #, to use the desktop display function, you actually use Shell. Application to execute the toggledesktop function,CodeAs follows:

  type  shelltype =  type . gettypefromprogid ( "shell. application ");  Object  shellobject = system.  activator . createinstance (shelltype); shelltype. invokemember ( "toggledesktop" , system. reflection.  bindingflags . invokemethod,  null , shellobject,  null  ); 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.