How to detect if you are running as admin in Vista?
Posted: (EET/GMT+2)
If you are developing Win32 applications for Windows Vista, you will quickly notice that even though your user account is part of the Administrators group, but default you are just a normal user. This is the workings of UAC.
I used to have code that was able to determine if the current user is an administrator, but now with Windows Vista this doesn't work anymore. This is because for example solutions given here depend on checking whether the current user belongs to the Administrators group. This used to work up to Windows XP, but not in Vista. Luckily, there's a Microsoft KB article 118626 that details a working solution in C/C++. If you are using Delphi, I'm currently working on an article that shares the Delphi code for this. Stay tuned.