帮满看下代码,类型不匹配。
Option Explicit之前出现ByRef参数类型不符合,修改和删除重整了一些代码后又出现了类型不匹配。 不要给我代码,帮我分析一下。 vb api
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function OpenProcessToken Lib "advapi32.dll" _
(ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) _
As Long
Public Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" _
(ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LARGE_INTEGER) _
As Long
Public Declare Function AdjustTokenPrivileges Lib "advapi32.dll" _
(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
Public Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) As Long
'----------------------------------------------
'ExitWindowsEX常数
Public Const EWX_FORCE = 4
Public Const EWX_LOGOFF = 0
Public Const EWX_REBOOT = 2
Public Const EWX_SHUTDOWN = 1
'-----------------------------------------------
Public Const SE_SECURITY_NAME = "SeSecurityPrivilege"
Public Const SE_PRIVILEGE_ENABLED = &H2
Public Const TOKEN_ADJUST_PRIVILEGES = &H20
'----------------------------------------------
Public Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type
Public Type LARGE_INTEGER_AND_ATTRIBUTES
pLuid As LARGE_INTEGER
Attributes As Long
End Type
Public Type TOKEN_PRIVILEGES
PrivilegeCount As Integer
Privileges As LARGE_INTEGER_AND_ATTRIBUTES
End Type
'---------------------------------------------------
Private Sub Command1_Click()
Dim jieshou As Long
Dim q As TOKEN_PRIVILEGES
Dim w As LARGE_INTEGER
Dim Privileges As TOKEN_PRIVILEGES
Dim gg As Long
Dim cc As TOKEN_PRIVILEGES
q.PrivilegeCount = 1
q.Privileges.Attributes = SE_PRIVILEGE_ENABLED
q.Privileges.pLuid = w
OpenProcessToken GetCurrentProcess(), (SE_SECURITY_NAME), jieshou
AdjustTokenPrivileges jieshou, False, q, Len(Privileges), cc, gg
ExitWindowsEx 0, EWX_LOGOFF
End Sub