VB6 is application running as administrator

一笑奈何 提交于 2019-12-23 13:05:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!