Attribute VB_Name = "Module1"
Option Explicit
Const EWX_LogOff As Long = 0
Const EWX_SHUTDOWN As Long = 1
Const EWX_REBOOT As Long = 2
Const EWX_FORCE As Long = 4
Const EWX_POWEROFF As Long = 8 'The ExitWindowsEx function either logs off, shuts down, or shuts
'down and restarts the system.
Declare Function ExitWindowsEx Lib "user32" _
(ByVal dwOptions As Long, _
ByVal dwReserved As Long) As Long 'The GetLastError function returns the calling thread's last-error
'code value. The last-error code is maintained on a per-thread basis.
'Multiple threads do not overwrite each other's last-error code.
Declare Function GetLastError Lib "kernel32" () As Long
Const mlngWindows95 = 0
Const mlngWindowsNT = 1
Public glngWhichWindows32 As Long
'The GetVersion function returns the operating system in use.
Declare Function GetVersion Lib "kernel32" () As Long
Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type
Type LUID_AND_ATTRIBUTES
TheLuid As LUID
Attributes As Long
End Type
Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type
'The GetCurrentProcess function returns a pseudohandle for the
'current process.
Declare Function GetCurrentProcess Lib "kernel32" () As Long
'The OpenProcessToken function opens the access token associated with
'a process.
Declare Function OpenProcessToken Lib "advapi32" _
(ByVal ProcessHandle As Long, _ByVal DesiredAccess As Long, _
TokenHandle As Long) As Long