Vraag & Antwoord

Programmeren

[vb6] Het systeem uitzetten

2 antwoorden
  • Ik wil graag mijn pc op een bepaalde tijd automatisch uitzetten, weet iemand hoe ik dit in VB kan doen?
  • http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20188308.html veel plz ;) [code:1:fbc13452ce] Private Type LUID LowPart As Long HighPart As Long End Type Private Type TOKEN_PRIVILEGES PrivilegeCount As Long LuidUDT As LUID Attributes As Long End Type Const TOKEN_ADJUST_PRIVILEGES = &H20 Const TOKEN_QUERY = &H8 Const SE_PRIVILEGE_ENABLED = &H2 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Private Declare Function GetVersion Lib "kernel32" () As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As Any, ReturnLength As Any) As Long Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long Sub ShutDownWindows(ByVal Reboot As Boolean, Optional ByVal Force As Boolean) Dim hToken As Long Dim tp As TOKEN_PRIVILEGES Dim flags As Long If GetVersion() >= 0 Then OpenProcessToken GetCurrentProcess(), (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hToken LookupPrivilegeValue "", "SeShutdownPrivilege", tp.LuidUDT tp.PrivilegeCount = 1 tp.Attributes = SE_PRIVILEGE_ENABLED AdjustTokenPrivileges hToken, False, tp, 0, ByVal 0&, ByVal 0& End If flags = EWX_SHUTDOWN If Reboot Then flags = flags Or EWX_REBOOT If Force Then flags = flags Or EWX_FORCE ExitWindowsEx flags, &HFFFF End Sub Private Sub cmdTest_Click() Call ShutDownWindows(True) End Sub [/code:1:fbc13452ce]

Beantwoord deze vraag

Weet jij het antwoord op deze vraag? Registreer of meld je aan met je account

Dit is een gearchiveerde pagina. Antwoorden is niet meer mogelijk.