Created
February 8, 2014 13:34
-
-
Save cxfksword/8883795 to your computer and use it in GitHub Desktop.
C#中执行windows显示桌面命令
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool ToggleDesktop() | |
{ | |
var success = true; | |
Type shellType = Type.GetTypeFromProgID("Shell.Application"); | |
if (shellType != null) | |
{ | |
try | |
{ | |
object shellObject = Activator.CreateInstance(shellType); | |
shellType.InvokeMember("ToggleDesktop", BindingFlags.InvokeMethod, null, shellObject, null); | |
} | |
catch | |
{ | |
success = false; | |
} | |
} | |
return success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment