AdjustTokenPrivileges The AdjustTokenPrivileges function enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access. BOOL AdjustTokenPrivileges( HANDLE TokenHandle, // handle to token that contains privileges BOOL DisableAllPrivileges, // flag for disabling all privileges PTOKEN_PRIVILEGES NewState, // pointer to new privilege information DWORD BufferLength, // size, in bytes, of the PreviousState buffer PTOKEN_PRIVILEGES PreviousState, // receives original state of changed // privileges PDWORD ReturnLength // receives required size of the // PreviousState buffer );
Private Declare Function RtlAdjustPrivilege Lib "ntdll.dll" (ByVal Privilege As Long, ByVal Enable As Boolean, ByVal Client As Boolean, WasEnabled As Long) As Long
Public Function EnablePrivilege(ByVal Privilege As Long, Enable As Boolean) As Boolean Dim ntStatus As Long Dim WasEnabled As Long ntStatus = RtlAdjustPrivilege(Privilege, Enable, True, WasEnabled) If ntStatus = STATUS_NO_TOKEN Then ntStatus = RtlAdjustPrivilege(Privilege, Enable, False, WasEnabled) End If If ntStatus = 0 Then EnablePrivilege = True Else EnablePrivilege = False End If End Function本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/chenhui530/archive/2008/06/01/2500112.aspx
The AdjustTokenPrivileges function enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access. BOOL AdjustTokenPrivileges(
HANDLE TokenHandle, // handle to token that contains privileges
BOOL DisableAllPrivileges,
// flag for disabling all privileges
PTOKEN_PRIVILEGES NewState,
// pointer to new privilege information
DWORD BufferLength, // size, in bytes, of the PreviousState buffer
PTOKEN_PRIVILEGES PreviousState,
// receives original state of changed
// privileges
PDWORD ReturnLength // receives required size of the
// PreviousState buffer
);
Public Function EnablePrivilege(ByVal Privilege As Long, Enable As Boolean) As Boolean
Dim ntStatus As Long
Dim WasEnabled As Long
ntStatus = RtlAdjustPrivilege(Privilege, Enable, True, WasEnabled)
If ntStatus = STATUS_NO_TOKEN Then
ntStatus = RtlAdjustPrivilege(Privilege, Enable, False, WasEnabled)
End If
If ntStatus = 0 Then
EnablePrivilege = True
Else
EnablePrivilege = False
End If
End Function本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/chenhui530/archive/2008/06/01/2500112.aspx
LookupPrivilegeValue()
AdjustTokenPrivileges()
没看出来
问题解决