tags:

views:

165

answers:

2

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).

+3  A: 

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)

Anders
Ahhhh ... how did I miss that? Thanks!
Rob
A: 

Duplicate question, see here: http://stackoverflow.com/questions/581204/how-do-i-check-if-a-user-has-local-admin-privileges-in-win32

It gets a bit more complex on Vista due to UAC and elevation but my answer to the other question contains some code that uses CheckTokenMembership() and uses the elevation type to work things out...

Len Holgate