ifyState = False
MsgBox "OpenProcessToken failed with error code " _
& Err.LastDllError
Exit Function
End If
Result = LookupPrivilegeValue(vbNullString, Privilege, PrivilegeId)
If (Result = 0) Then
ModifyState = False
MsgBox "LookupPrivilegeValue failed with error code " _
& Err.LastDllError
Exit Function
End If
MyPrives.Privileges(0).pLuid = PrivilegeId
MyPrives.PrivilegeCount = 1
If (Enable) Then
MyPrives.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
Else
MyPrives.Privileges(0).Attributes = 0
End If
Result = AdjustTokenPrivileges(hToken, False, MyPrives, 0, 0, 0)
If (Result = 0 Or Err.LastDllError <> 0) Then
ModifyState = False
MsgBox "AdjustTokenPrivileges failed with error code " _
& Err.LastDllError
Exit Function
End If
CloseHandle hToken
ModifyState = True
End Function