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:

Declare Function WTSShutdownSystem Lib "wtsapi32.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

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