English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

VB的關機問題
我已經會
打開XP的權限了,也可以順利關機了,但是有一個問題我很困擾
EWX_POWEROFF 不是關機並關電源嗎?
要把EWX_POWEROFF = 8才可以
但是關機時還是會出現\"您現在可以放心關機\"

我知道為什麼,因為:
NT/2000/XP系統的不能直接這樣
還要打開SE_SHUTDOWN_NAME才可以
但是我不知道如何打開...

2006-06-13 17:32:13 · 3 個解答 · 發問者 阿不拉 2 in 電腦與網際網路 程式設計

3 個解答

Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type
Private Const EWX_SHUTDOWN = 1
Private Const EWX_POWEROFF = 8
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) 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 TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Sub SdW()
Dim P As Long, T As Long, L As LUID, S As TOKEN_PRIVILEGES, D As TOKEN_PRIVILEGES, E As Long
P = GetCurrentProcess()
OpenProcessToken P, (&H20 Or &H8), T
LookupPrivilegeValue "", "SeShutdownPrivilege", L
S.PrivilegeCount = 1: S.TheLuid = L: S.Attributes = &H2
AdjustTokenPrivileges T, False, S, Len(D), D, E
End Sub
Private Sub Command1_Click()
SdW
ExitWindowsEx EWX_SHUTDOWN + EWX_POWEROFF, &HFFFF
End Sub

2006-06-28 07:11:56 · answer #1 · answered by 4 · 0 0

......
兩個根本一樣..= =

2006-06-29 17:54:07 · answer #2 · answered by 阿不拉 2 · 0 0

請參考:http://tw.knowledge.yahoo.com/question/?qid=1405121406120

2006-06-14 11:10:41 · answer #3 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers