您好,登錄后才能下訂單哦!
這篇文章主要介紹了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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。