As you can see from the screenshot below, I am logged in to what is apparently an administrator account. (I also have a limited account that I normally log into). But, despite what you see below, I still have to accept UAC prompts to run RegEdit and other such tools, and the code below returns 0 for all three admin tests.
What the heck is going on? How can my app know if it's running with admin rights?
Code: Select all
Procedure IsAdmin()
a=OpenSCManager_(0,0,#SC_MANAGER_ALL_ACCESS)
If a : CloseServiceHandle_(a) : EndIf
ProcedureReturn a
EndProcedure
Debug IsAdmin() ; Returns 0
Debug IsUserAdmin_() ; Returns 0
Debug IsUserAnAdmin_() ; Returns 0