问题
Is there any way of finding out if the application is running as administrator?
If this involves a COM call, I'm not really fussed, anything that works!
回答1:
IsUserAnAdmin is an easy call and seems perfectly reliable for use in VB6 programs. It seems to work fine even in Win8.
Note that it reports whether the process is running with admin rights, not whether the user is in the Administrators group.
Declaring it this way it should work all the way back to Windows 2000:
Private Declare Function IsUserAnAdmin Lib "shell32" Alias "#680" () As Long
回答2:
You can use the CheckTokenMembership() function with the admin SID. I've not tried calling this from VB though. (Taken from the Inno IsAdminLoggedOn() function.
来源:https://stackoverflow.com/questions/8416665/vb6-is-application-running-as-administrator