Is there any APIs in windows to detect whether the current user(current now) has the admin authority?
BOOL IsHasAuthority() { }
Many Thanks!
Is there any APIs in windows to detect whether the current user(current now) has the admin authority?
BOOL IsHasAuthority() { }
Many Thanks!
You can use the Windows API function CheckTokenMembership()
. The MSDN documentation for that function has an example demonstrating how to check for membership in the Administrators local group.
How to Determine Whether a Process or Thread Is Running As an Administrator
Use this solution when you are writing an application that must determine whether any of the following is true:
- The current user can perform administrative tasks. The current
user is a member of the- Administrators group. A supplied token handle represents an
administrator with an elevated token.- A token handle represents a user who is a member of the Administrators group.
- The program is running with an elevated token or needs to spawn a
child program that is elevated so it
can perform administrative tasks.