以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]是否可以判断软件是不是用管理员权限打开的  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=165232)

--  作者:81538475
--  发布时间:2021/5/11 12:07:00
--  [求助]是否可以判断软件是不是用管理员权限打开的
是否可以判断发布后的软件是不是用管理员权限打开的
--  作者:有点蓝
--  发布时间:2021/5/11 13:31:00
--  
参考:http://www.foxtable.com/webhelp/topics/0609.htm
--  作者:81538475
--  发布时间:2021/5/11 13:59:00
--  
找到了。我是需要判断电脑操作系统的管理员哈。
If My.User.IsInRole(Microsoft.VisualBasic.ApplicationServices.BuiltInRole.Administrator) Then
    
    MsgBox("管理员")
    
Else
    
    MsgBox("不是管理员")
    
End If

--  作者:81538475
--  发布时间:2021/5/11 14:14:00
--  
奇怪了。在VS里面可以判断,但是foxtable里面为啥判断不出来呢。
--  作者:81538475
--  发布时间:2021/5/11 14:38:00
--  
有其他方法判断吗图片点击可在新窗口打开查看
--  作者:有点蓝
--  发布时间:2021/5/11 14:53:00
--  
Dim current = System.Security.Principal.WindowsIdentity.GetCurrent()
Dim windowsPrincipal As new System.Security.Principal.WindowsPrincipal(current)
msgbox( windowsPrincipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))