Jump to content

How to figure out if UAC is active?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
vbigiani

vbigiani

    Newbie

  • Members
  • Pip
  • 4 posts
I have a console app that (in certain situations) does not work correctly when UAC is enabled. As such, I'd like to print out a warning (and, if possible, trigger an UAC authorization screen) if UAC is detected as activated. What is the code to do so?

If possible, I'd prefer code in C or C++ for the following functions:

/* returns 1 if UAC is enabled, 0 if disabled or the OS is a non-Vista  one */

int isUACEnabled()


/* triggers an UAC authorization dialogue, granting full access for the rest of the program's operation. Returns success or failure. */

int AskUAC()

I'm sorry if AskUAC() asks for something incompatible with how Vista works, I'm not any familiar with that.

I tried to search for UAC and "User Account Control", but the first search is disabled and the second didn't return anything relevant.

Many thanks for any answer.

#2
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
You need to use the registry to check and see if UAC is enabled. The value is 'EnableLUA' under 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'

If its a '1' then its enabled, else its disabled. If the value doesn't exist, its not running vista.

#3
vbigiani

vbigiani

    Newbie

  • Members
  • Pip
  • 4 posts
Many thanks for your reply. I'll reply back if I still need help.