[API]
LARGE_INTEGER
LUID_AND_ATTRIBUTES
OSVERSIONINFO
TOKEN_PRIVILEGES
LookupPrivilegeValueA
GetCurrentProcess
AdjustTokenPrivileges
OpenProcessToken
ExitWindowsEx
GetVersionExA

[CODE]
Public Function ShutDownWindows() As Boolean
  Dim xLong1 As Long
  Dim xLong2 As Long
  Dim xType1 As OSVERSIONINFO
  Dim xType2 As TOKEN_PRIVILEGES
  Dim xType3 As TOKEN_PRIVILEGES
  
  xType1.dwOSVersionInfoSize = Len(xType1)
  If Not GetVersionExA(xType1) = 0& Then
    If (xType1.dwPlatformId = &H2&) Then
      If OpenProcessToken(GetCurrentProcess(), 40&, xLong2) Then
        xLong1 = LookupPrivilegeValueA(vbNullString, "SeShutdownPrivilege", xType2.Privileges(0).pLuid)
        xType2.PrivilegeCount = 1&
        xType2.Privileges(0).Attributes = 2&
        Call AdjustTokenPrivileges(xLong2, 0&, xType2, LenB(xType3), xType3, xLong1)
        End If
      End If
    End If
  ShutDownWindows = Not (ExitWindowsEx(9&, 0&) = 0&)
  End Function
