Return to Snippet

Revision: 64356
at July 29, 2013 12:36 by FearTec


Initial Code
Imports System.Runtime.InteropServices

Public Class Form1

    <Flags()> _
    Enum ExitWindows As UInteger
        LogOff = &H0
        ShutDown = &H1
        Reboot = &H2
        PowerOff = &H8
        RestartApps = &H40
        ' plus AT MOST ONE of the following two:
        Force = &H4
        ForceIfHung = &H10
    End Enum

    Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Int32, ByVal dwReserved As Int32) As Int32

    Private Sub ForceLogoffNow()
        Call ExitWindowsEx(ExitWindows.LogOff, ExitWindows.Force)
    End Sub

Initial URL


Initial Description
Force Logoff in VB.NET via InteropServices

Initial Title
Force Logoff in VB.NET via InteropServices

Initial Tags


Initial Language
VB.NET