十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这篇文章主要介绍了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的问题示例”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!