您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍了VB.NET中Array的问题示例,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
本实例需要项目引用:
Imports Microsoft.Win32 '用途 : 注册表操作 Imports System.Security.AccessControl'用途 : 访问权限控制
首先,对注册表的键增加权限,细分起来共有11种可选的权限类型,它们对应的参数如下:
Select Case ComboBox1.Text Case "完全控制" ObjRegRight = RegistryRights.FullControl Case "查询数值" ObjRegRight = RegistryRights.QueryValues Case "设置数值" ObjRegRight = RegistryRights.SetValue Case "创建子项" ObjRegRight = RegistryRights.CreateSubKey Case "枚举子项" ObjRegRight = RegistryRights.EnumerateSubKeys Case "通知" ObjRegRight = RegistryRights.Notify Case "创建链接" ObjRegRight = RegistryRights.CreateLink Case "删除" ObjRegRight = RegistryRights.Delete Case "写入DAC" ObjRegRight = RegistryRights.WriteKey Case "写入所有者" ObjRegRight = RegistryRights.TakeOwnership Case "读取控制" ObjRegRight = RegistryRights.ReadPermissions End Select
而每个细分权限 又分"允许"和"拒绝"两种访问控制类型
Select Case ComboBox2.Text Case "允许" ObjRegAccess = AccessControlType.Allow Case "拒绝" ObjRegAccess = AccessControlType.Deny End Select
以下为增加注册表键权限的函数
以下两函数中 Account代表系统nt帐户 Rights和ControlType分别为上文提及的权限类型和访问控制类型
Private Sub AddRegistrySecurity(ByVal Str_FileName As String, ByVal Account As String, ByVal Rights As RegistryRights, ByVal ControlType As AccessControlType) Dim RegKey As RegistryRegistryKey = Registry.CurrentUser.CreateSubKey("此处填写具体键地址") Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl() Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Account, Rights, ControlType) RegkeyAcl.AddAccessRule(AccessRule) RegKey.SetAccessControl(RegkeyAcl) RegKey.Close() End Sub
以下为移除注册表键权限的函数
Private Sub RemoveRegistrySecurity(ByVal Str_FileName As String, ByVal Account As String, ByVal Rights As RegistryRights, ByVal ControlType As AccessControlType) Dim RegKey As RegistryRegistryKey = Registry.CurrentUser.CreateSubKey("此处填写具体键地址") Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl() Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Account, Rights, ControlType) RegkeyAcl.RemoveAccessRule(AccessRule) RegKey.SetAccessControl(RegkeyAcl) RegKey.Close() End Sub
感谢你能够认真阅读完这篇文章,希望小编分享的“VB.NET中Array的问题示例”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。