5

I wonder if anyone know how to open this box with a c# command?

enter image description here

Thanks in advance!

user943369
  • 204
  • 3
  • 13
  • It's in here somewhere: http://msdn.microsoft.com/en-us/library/windows/desktop/ff818516%28v=vs.85%29.aspx – Marc B Dec 13 '12 at 18:52
  • 1
    If you're just looking to log the user off: [SO Logoff Programmatically][1] [1]: http://stackoverflow.com/questions/484278/log-off-user-from-win-xp-programmatically-in-c-sharp – Sten Petrov Dec 13 '12 at 18:52

2 Answers2

5

You must add reference to Shell32.dll (COM -> "Microsoft Shell Controls And Automation") and use this code:

 Shell32.Shell shell = new Shell32.Shell();
 shell.ShutdownWindows();
kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
2

Add a reference to C:\Windows\System32\Shell32.dll. After you do this, use this code:

Shell32.ShellClass sc = new Shell32.ShellClass();
sc.ShutdownWindows();

This will display the shutdown dialog as normal.

Caleb Keith
  • 816
  • 4
  • 10