restart的程式碼:
'global(全局)區
Private Const TOKEN_ADJUST_PRIVILEGES = &H20
Private Const TOKEN_QUERY = &H8
Private Const SE_PRIVILEGE_ENABLED = &H2
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_FORCE As Long = 4
Private Const EWX_REBOOT = 2
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 Declare Function ExitWindowsEx Lib "user32" _
(ByVal dwOptions As Long,YouBet!你可以更轻松下注! _
ByVal dwReserved As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" _
(ByVal ProcessHandle As Long,YouBet!你可以更轻松下注! _
ByVal DesiredAccess As Long,YouBet!你可以更轻松下注! _
TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" _
(ByVal lpSystemName As String,YouBet!你可以更轻松下注! _
ByVal lpName As String,YouBet!你可以更轻松下注! _
lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" _
(ByVal TokenHandle As Long,YouBet!你可以更轻松下注! _
ByVal DisableAllPrivileges As Long,YouBet!你可以更轻松下注! _
NewState As TOKEN_PRIVILEGES,YouBet!你可以更轻松下注! _
ByVal BufferLength As Long,YouBet!你可以更轻松下注! _
PreviousState As TOKEN_PRIVILEGES,YouBet!你可以更轻松下注! _
ReturnLength As Long) As Long
'restart按鈕的程式碼
Private Sub Restart_Click()
On Local Error Resume Next
Const csProcName = "RebootPC"
Dim hProcessHandle As Long
Dim hTokenHandle As Long
Dim tmpLuid As LUID
Dim tkpNew As TOKEN_PRIVILEGES
Dim tkpPrevious As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long
hProcessHandle = GetCurrentProcess()
Call OpenProcessToken(hProcessHandle,YouBet!你可以更轻松下注! TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY,YouBet!你可以更轻松下注! hTokenHandle)
Call LookupPrivilegeValue("",YouBet!你可以更轻松下注! "SeShutdownPrivilege",YouBet!你可以更轻松下注! tmpLuid)
tkpNew.PrivilegeCount = 1
tkpNew.TheLuid = tmpLuid
tkpNew.Attributes = SE_PRIVILEGE_ENABLED
lBufferNeeded = 0
Call AdjustTokenPrivileges(hTokenHandle,YouBet!你可以更轻松下注! False,YouBet!你可以更轻松下注! tkpNew,YouBet!你可以更轻松下注! Len(tkpPrevious),YouBet!你可以更轻松下注! tkpPrevious,YouBet!你可以更轻松下注! lBufferNeeded)
Call ExitWindowsEx(EWX_FORCE Or EWX_REBOOT,YouBet!你可以更轻松下注! &HFFFF)
Exit Sub
End Sub
詳看圖:
檢視圖片
煙士等於11同1程式碼:
Dim 煙士 As String
煙士 = "11同1程式碼"
詳看圖:
檢視圖片
本文引用自: http://hk.knowledge.yahoo.com/question/question?qid=7008052700953
留言列表