Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "ShutDown" in [All]

Structures

.

    ''' this entrypoint is called during process initialization and shutdown and  

.

    ' entrypoint is called during process initialization and shutdown and during thread creations/

.

    ' entrypoint is called during process initialization and shutdown and during thread creations/

.

   PowerActionShutdown,       // Shutdown.

.

   PowerActionShutdownReset,  // Shutdown and reset.

.

   PowerActionShutdownOff,    // Shutdown and power off.

.

   POWER_USER_NOTIFY_SHUTDOWN    = 0x00000010, // Indicates a power action of shutdown/off.

.

   PowerActionShutdown    ' Shutdown.

.

   PowerActionShutdownReset   ' Shutdown and reset.

.

   PowerActionShutdownOff     ' Shutdown and power off.

.

   POWER_USER_NOTIFY_SHUTDOWN = &H10      ' Indicates a power action of shutdown/off.

.

        SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100,

.

        SERVICE_ACCEPT_SHUTDOWN = 0x00000004,

.

    PowerSystemShutdown = 6,

.

    PowerSystemShutdown = 6

aygshell

.

    EWX_SHUTDOWN = 1,

.

        Specifies the type of shutdown. This parameter must be one of the following values:

.

Available only at Windows Mobile 5.0 or later. The ExitWindowsEx function returns as soon as it has initiated the shutdown. The shutdown then proceeds asynchronously. Because the function executes asynchronously, a nonzero return value indicates that the shutdown has been initiated. It does not indicate whether the shutdown will succeed. It is possible that the system, the user, or another application will abort the shutdown.

user32

.
Summary
Cancels shutdown of the computer. Same as console command "Shutdown -a"
.

static extern int CancelShutdown();

.

Declare Function CancelShutdown Lib "user32.dll" () As Integer

.

  System.Diagnostics.Process.Start("Shutdown", "-a");

.

One does not simply shutdown a computer.

.

CancelShutdown();

.
Documentation
[CancelShutdown] on MSDN
.

  static extern bool EndTask(IntPtr hWnd, bool fShutDown, bool fForce);

.

  Private Shared Function EndTask(hWnd As IntPtr, fShutDown As Boolean, fForce As Boolean) As Boolean

.

    public static extern bool EndTask(IntPtr hWnd, bool fShutDown,bool fForce);

.

        // fShutDown = true will kill the window instantly

.

        // fShutDown = false will show the message box before closing for Saving Changes

.

    Public Shared Function EndTask(hWnd As IntPtr, fShutDown As Boolean, fForce As Boolean) As Boolean

.

static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);

.

     ByVal dwReason As ShutdownReason) As <MarshalAs(UnmanagedType.Bool)> Boolean

.
  • dwReason - See ShutdownReason
.

To shut down or restart the system on NT/2K/XP, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege.

.

            ExitWindowsEx(ExitWindows.LogOff, ShutdownReason.MajorOther | ShutdownReason.MinorOther);

.

Changed the sample code Reason parameter from "&" to "ShutdownReason.MajorOther | ShutdownReason.MinorOther". Amperstand (&) is the binary AND condition, and the values ANDed together would be zero. The intended condition is that the flags be ORed together. (|)

.
Summary
Indicates that the system cannot be shut down and sets a reason string to be displayed to the user if system shutdown is initiated.
.

static extern bool ShutdownBlockReasonCreate(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string reason);

.

Declare Function ShutdownBlockReasonCreate Lib "user32.dll" (ByVal hWnd As IntPtr, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal reason As String) As Boolean

.

reason - The reason the application must block system shutdown.

.
  • Invisible windows won't show up in Vista's "Running Applications" dialog on shutdown/logoff and therefore the reason set with this method will not be visible to the end-user .
.

IntPtr handleForShutdownBlocker = shutdownBlockingForm.Handle;

.

if (!ShutdownBlockReasonCreate(handleForShutdownBlocker, UIMessages.GetString("ShutdownBlockReason"))) {

.

    log.Error(string.Format("Failed calling ShutdownBlockReasonCreate. Error code: {0}, blocking form handle: {1}", error, handleForShutdownBlocker));

.
Documentation
[ShutdownBlockReasonCreate] on MSDN
.

static extern bool ShutdownBlockReasonDestroy(IntPtr hWnd);

.

Declare Function ShutdownBlockReasonDestroy Lib "user32.dll" (hWnd As IntPtr) As Boolean

.
Documentation
[ShutdownBlockReasonDestroy] on MSDN

powrprof

.

static extern bool IsPwrShutdownAllowed();

.

Declare Function IsPwrShutdownAllowed Lib "powrprof.dll" () As Boolean

.
Documentation
[IsPwrShutdownAllowed] on MSDN

ws2_32

.

    //you may add sck.Shutdown(SocketShutdown.Both);

.

    public static extern int shutdown(IntPtr s, ShutDownFlags how);

.

Declare Function shutdown Lib "ws2_32.dll" (TODO) As TODO

.

    public enum ShutDownFlags : int

.
Documentation
[shutdown] on MSDN

kernel32

.

        CTRL_SHUTDOWN_EVENT

.

private void shutdownToolStripMenuItem_Click(object sender, EventArgs e)

.
Summary
.

static extern bool GetProcessShutdownParameters(out uint lpdwLevel,

.
Documentation
[GetProcessShutdownParameters] on MSDN
.

        CTRL_SHUTDOWN_EVENT

.

For a Windows application that is being updated, the last opportunity to call this function is while processing the WM_QUERYENDSESSION message. For a console application that is being updated, the registration must occur before the installer tries to shutdown the application (you need to keep the registration current; you cannot call this function when handling the CTRL_C_EVENT notification).

.

Note that for an application to be restarted when the update requires a computer restart, the installer must call the ExitWindowsEx function with the EWX_RESTARTAPPS flag set or the InitiateShutdown function with the SHUTDOWN_RESTARTAPPS flag set.

.

    CTRL_SHUTDOWN_EVENT

.

   CTRL_SHUTDOWN_EVENT

coredll

.

public static extern uint lineShutdown(IntPtr hLineApp);

.
Documentation
[lineShutDown] on MSDN

advapi32

.

   Privileges.EnablePrivilege(SecurityEntity.SE_SHUTDOWN_NAME);

.

        case SecurityEntity.SE_REMOTE_SHUTDOWN_NAME:

.

           return "SeRemoteShutdownPrivilege";

.

        case SecurityEntity.SE_SHUTDOWN_NAME:

.

           return "SeShutdownPrivilege";

.

      SE_SHUTDOWN_NAME,

.

      SE_REMOTE_SHUTDOWN_NAME,

.

    'This routine enables the Shutdown privilege for the current process,

.

    Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege"

.

    Public Sub AcquireShutdownPrivilege()

.

        'Get the LUID that corresponds to the Shutdown privilege, if it exists.

.

        Dim luid_Shutdown As LUID

.

        If Not LookupPrivilegeValue(Nothing, SE_SHUTDOWN_NAME, luid_Shutdown) Then

.

            'Set up a LUID_AND_ATTRIBUTES structure containing the Shutdown privilege, marked as enabled.

.

            luaAttr.Luid = luid_Shutdown

.

            'Set up a TOKEN_PRIVILEGES structure containing only the shutdown privilege.

.

7    SERVICE_CONFIG_PRESHUTDOWN_INFO

.

7    SERVICE_CONFIG_PRESHUTDOWN_INFO

.

    SHUTDOWN           = 0x00000005,

.

    SHUTDOWN        = 0x00000004,

.

    SHUTDOWN = &H5

.

    SHUTDOWN = &H4

.
Summary
Initiates a shutdown and restart of the specified computer, and restarts any applications that have been registered for restart.
.

  static extern UInt32 InitiateShutdown(

.

    UInt32 dwShutdownFlags,

.

    ' InitiateShutdown

.

    Friend Shared Function InitiateShutdown( _

.

     ByVal dwShutdownFlags As UInt32, _

.

    ' used with InitiateShutdown

.

    Friend Enum ShutdownFlags As UInt32

.

     SHUTDOWN_FORCE_OTHERS = &H1     ' all sessions are forcefully logged off

.

     SHUTDOWN_FORCE_SELF = &H2       ' the originating session is forcefully logged off

.

     SHUTDOWN_RESTART = &H4      ' shut down and reboot

.

     SHUTDOWN_POWEROFF = &H8     ' shut down and power down

.

     SHUTDOWN_NOREBOOT = &H10    ' shut down but don't power down nor reboot

.

     SHUTDOWN_GRACE_OVERRIDE = &H20  ' override the grace period (shut down immediately)

.

     SHUTDOWN_INSTALL_UPDATES = &H40 ' install pending Windows updates before starting the shutdown

.

     SHUTDOWN_RESTARTAPPS = &H80     ' restart applications that have been registered for restart using the RegisterApplicationRestart function

.

     SHUTDOWN_HYBRID = &H200     ' for Win8 and above: perform a hybrid shutdown (log out the users and hibernate the kernel)

.
Documentation
[InitiateShutdown] on MSDN
.
Summary
Initiates a shutdown and optional restart of the specified computer, and optionally records the reason for the shutdown.
.

public static extern bool InitiateSystemShutdownEx(

.

    bool bRebootAfterShutdown,

.

    ShutdownReason dwReason);

.

  public enum ShutdownReason : uint

.

Public Function InitiateSystemShutdownEx( _

.

     <MarshalAs(UnmanagedType.Bool)> ByVal bRebootAfterShutdown As Boolean, _

.

     ByVal ShutdownReason As ShutdownReason) As <MarshalAs(UnmanagedType.Bool)> Boolean

.

    Public Enum ShutdownReason As UInteger

.

dwReason: The ShutdownReason enum can be used for this parameter.

.
Summary
Initiates a shutdown and optional restart of the specified computer, and optionally records the reason for the shutdown.
.

public static extern bool InitiateSystemShutdownEx(

.

    bool bRebootAfterShutdown,

.

    ShutdownReason dwReason);

.

  public enum ShutdownReason : uint

.

Public Function InitiateSystemShutdownEx( _

.

     <MarshalAs(UnmanagedType.Bool)> ByVal bRebootAfterShutdown As Boolean, _

.

     ByVal ShutdownReason As ShutdownReason) As <MarshalAs(UnmanagedType.Bool)> Boolean

.

    Public Enum ShutdownReason As UInteger

.

dwReason: The ShutdownReason enum can be used for this parameter.

.
Documentation
[InitiateSystemShutdownEx] on MSDN
.

public const string SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege";

.

public const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";

.

if (!LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, out tkp.Privileges[0].Luid))

.

static extern TODO ShutDown(TODO);

.

Declare Function ShutDown Lib "advapi32.dll" (TODO) As TODO

.
Documentation
[ShutDown] on MSDN

Enums

.
Summary
Defines the Shutdown type for the user32.ExitWindowsEx method
.

   ShutDown = 0x01,

.

     ShutDown = &H1

.

    ///A system shutdown is in progress.

.

    [Description("A system shutdown is in progress.")]

.

    public const int SEC_E_SHUTDOWN_IN_PROGRESS = unchecked((int)0x8009033F);

.

    public const int SCARD_P_SHUTDOWN = unchecked((int)0x80100018);

.

    '''A system shutdown is in progress.

.

    <Description("A system shutdown is in progress.")> _

.

    Public Const SEC_E_SHUTDOWN_IN_PROGRESS As Integer = CInt(&H8009033fUI)

.

    Public Const SCARD_P_SHUTDOWN As Integer = CInt(&H80100018UI)

.

            PowerActionShutdownPowerActionShutdown,

.

            PowerActionShutdownResetPowerActionShutdownReset,

.

            PowerActionShutdownOffPowerActionShutdownOff,

.

    /// Shutdown action masked by filer.

.

    RmStatusShutdownMasked = 0x40,

.
Summary
Defines the Shutdown reason for the user32.ExitWindowsEx method
.

enum ShutdownReason : uint

.

Enum ShutdownReason As UInteger

.
Documentation
[ShutdownReason] on MSDN
.

   PowerSystemShutdownPowerSystemShutdown = 6,

.

    /// The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero.

.

    '''The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions. If any application returns zero the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. After processing this message the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message.

.

    ''' system shutdown functions.

Constants

38: EWX
.

private const UInt32 EWX_SHUTDOWN        = 0x00000001;

39: NERR_
.

        public const int UPSShutdownFailed = 2484;

.

        /// A system shutdown is in progress.

.

        public const int ERROR_SHUTDOWN_IN_PROGRESS = 1115;

.

        /// Unable to abort the system shutdown because no shutdown was in progress.

.

        public const int ERROR_NO_SHUTDOWN_IN_PROGRESS = 1116;

.

        public const int ERROR_SERVER_SHUTDOWN_IN_PROGRESS = 1255;

.

        public const int ERROR_SHUTDOWN_CLUSTER = 5008;

.

        /// The membership engine requested shutdown of the cluster service on this node.

.

        public const int ERROR_DS_DRA_SHUTDOWN = 8463;

.

        /// Error Status: 0x%2. Please click OK to shutdown the system. You can use the recovery console to diagnose the system further.

.

        /// Error Status: 0x%2. Please click OK to shutdown the system. You can use the recovery console to diagnose the system further.

.

        /// The operation cannot be performed because this zone is shutdown.

.

        public const int DNS_ERROR_ZONE_IS_SHUTDOWN = 9621;

.

        /// A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call.

.

        public const int WSAESHUTDOWN = 10058;

.

        /// Returned by WSARecv or WSARecvFrom to indicate the remote party has initiated a graceful shutdown sequence.

.

        /// A system shutdown is in progress.

.

        public const int SEC_E_SHUTDOWN_IN_PROGRESS = (int)(0x8009033F - 0x100000000);

.

        public const int SCARD_P_SHUTDOWN = (int)(0x80100018 - 0x100000000);

41: WINNT
.

private const string SE_SHUTDOWN_NAME    = "SeShutdownPrivilege";

.

Private Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege"

42: WM
.
WM_QUERYENDSESSION 0x11 The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. After processing this message, the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message.

wtsapi32

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

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

.

  Private Shared Function WTSShutdownSystem(ByVal hServer As IntPtr, ByVal ShutdownFlags As Long) As Integer

.

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

.

private const long WTS_WSD_SHUTDOWN = 0x00000002;

.

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

.

    WTSShutdownSystem(new IntPtr(0), WTS_WSD_REBOOT);

.
Documentation
[WTSShutdownSystem] on MSDN

ntdll

.

SE_SHUTDOWN_PRIVILEGE = 19

gdiplus

.
Summary
The GdiplusShutdown function cleans up resources used by GDI+. Each call to GdiplusStartup should be paired with a call to GdiplusShutdown.
.

static extern void GdiplusShutdown(ref IntPtr token);

.

Declare Function GdiplusShutdown Lib "gdiplus.dll" (TODO) As TODO

.
Documentation
[GdiplusShutdown] on MSDN
.
Summary
The GdiplusStartup function initializes Windows GDI+. Call GdiplusStartup before making any other GDI+ calls. Call GdiplusShutdown when you have finished using GDI+.

 
Access PInvoke.net directly from VS: