views:

232

answers:

3

Hi

in my code I need to detect if current user has rights to install other application (other application VC2005 redist. package)... and it should work on Vista.

As I understand CheckTokenMembership or IsAdministrator do not give a complete solution.

Thank you

A: 

Check out the PrivilegeCheck function: http://msdn.microsoft.com/en-us/library/aa379304(VS.85).aspx

Piskvor
+1  A: 

It is not the way UAC works, 99.99% of the time the answer will be No. You get access by asking for it. Include a manifest in your installer. The redist installer already has that manifest.

Hans Passant
+1  A: 

While the currently logged in user might not have rights to install, they may still be prompted with an authentication dialog ("over the shoulder" install). If a valid username and password is entered on this dialog, they can install. So this isn't something you can reliably check as the user is technically "allowed" but only once they enter a correct username/password.

Your best solution is to attempt to elevate and fail gracefully if that fails :)

sascha