WTSShutdownSystem (wtsapi32)
Last changed: -72.243.186.254

.
Summary
The WTSShutdownSystem function shuts down (and optionally restarts) the specified terminal server.

C# Signature:

[DllImport("wtsapi32.dll", SetLastError=true)]
public static extern int WTSShutdownSystem(IntPtr ServerHandle, long ShutdownFlags);

VB Signature:

  <DllImport("wtsapi32.dll", SetLastError:=True)> _
  Private Shared Function WTSShutdownSystem(ByVal hServer As IntPtr, ByVal ShutdownFlags As Long) As Integer
  End Function

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/wtsshutdownsystem.asp

Tips & Tricks:

Please add some!

Sample Code:

private const long WTS_WSD_REBOOT = 0x00000004;

private const long WTS_WSD_SHUTDOWN = 0x00000002;

[DllImport("wtsapi32.dll")]

public static extern int WTSShutdownSystem(IntPtr ServerHandle, long ShutdownFlags);

static void Main()

{

    //WTS_CURRENT_SERVER_HANDLE = 0
    WTSShutdownSystem(new IntPtr(0), WTS_WSD_REBOOT);

}

Documentation