Skip to content

Instantly share code, notes, and snippets.

@cxfksword
Created February 8, 2014 13:34
Show Gist options
  • Save cxfksword/8883795 to your computer and use it in GitHub Desktop.
Save cxfksword/8883795 to your computer and use it in GitHub Desktop.
C#中执行windows显示桌面命令
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