Discover if user has Admin rights

c, c++, winapi, windows

Solution

IsUserAnAdmin() is the fast and easy way, but MSDN warns that it might go away in the future, so you might want to call CheckTokenMembership() on your thread/process token instead (Comparing with a well known sid for the admin group)

Problem

How can I determine if the current user (the user running my application) has admin rights (i.e. is a member of the Administrator group)? I need to register some COM components differently for users with limited access. I am using C++ (WTL and Win32).

Original source