自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

VB.NET實例教程對關于Array問題的解決

開發(fā) 后端
VB.NET實例教程教你解決關于Array的問題,對注冊表的鍵增加權限,細分起來共有11種可選的權限類型,想知道是什么嗎,請看文章正為。

在VB.NET中大家有沒有遇到過有關于Array的問題,VB.NET實例教程教你如何解決這個問題,大家快來嘗試一下吧。

VB.NET實例教程Array案例:

本實例需要項目引用:

  1. Imports Microsoft.Win32  '用途 : 注冊表操作  
  2. Imports System.Security.AccessControl'用途 : 訪問權限控制  

首先,對注冊表的鍵增加權限,細分起來共有11種可選的權限類型,它們對應的參數(shù)如下:

  1. Select Case ComboBox1.Text  
  2. Case "完全控制"  
  3. ObjRegRight = RegistryRights.FullControl  
  4. Case "查詢數(shù)值"  
  5. ObjRegRight = RegistryRights.QueryValues  
  6. Case "設置數(shù)值"  
  7. ObjRegRight = RegistryRights.SetValue  
  8. Case "創(chuàng)建子項"  
  9. ObjRegRight = RegistryRights.CreateSubKey  
  10. Case "枚舉子項"  
  11. ObjRegRight = RegistryRights.EnumerateSubKeys  
  12. Case "通知"  
  13. ObjRegRight = RegistryRights.Notify  
  14. Case "創(chuàng)建鏈接"  
  15. ObjRegRight = RegistryRights.CreateLink  
  16. Case "刪除"  
  17. ObjRegRight = RegistryRights.Delete   
  18. Case "寫入DAC"  
  19. ObjRegRight = RegistryRights.WriteKey  
  20. Case "寫入所有者"  
  21. ObjRegRight = RegistryRights.TakeOwnership  
  22. Case "讀取控制"  
  23. ObjRegRight = RegistryRights.ReadPermissions  
  24. End Select 

而每個細分權限 又分"允許"和"拒絕"兩種訪問控制類型

  1. Select Case ComboBox2.Text  
  2. Case "允許"  
  3. ObjRegAccess = AccessControlType.Allow  
  4. Case "拒絕"  
  5. ObjRegAccess = AccessControlType.Deny  
  6. End Select 

以下為增加注冊表鍵權限的函數(shù)

以下兩函數(shù)中 Account代表系統(tǒng)nt帳戶  Rights和ControlType分別為上文提及的權限類型和訪問控制類型

  1. Private Sub AddRegistrySecurity(ByVal Str_FileName As String, ByVal Account As String, ByVal Rights As RegistryRights, ByVal ControlType As AccessControlType)  
  2. Dim RegKey As RegistryRegistryKey = Registry.CurrentUser.CreateSubKey("此處填寫具體鍵地址")  
  3. Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl()  
  4. Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Account, Rights, ControlType)  
  5. RegkeyAcl.AddAccessRule(AccessRule)  
  6. RegKey.SetAccessControl(RegkeyAcl)  
  7. RegKey.Close()  
  8. End Sub 


以下為移除注冊表鍵權限的函數(shù)

  1. Private Sub RemoveRegistrySecurity(ByVal Str_FileName As String, ByVal Account As String, ByVal Rights As RegistryRights, ByVal ControlType As AccessControlType)  
  2. Dim RegKey As RegistryRegistryKey = Registry.CurrentUser.CreateSubKey("此處填寫具體鍵地址")  
  3. Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl()  
  4. Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Account, Rights, ControlType)  
  5. RegkeyAcl.RemoveAccessRule(AccessRule)  
  6. RegKey.SetAccessControl(RegkeyAcl)  
  7. RegKey.Close()  
  8. End Sub 

VB.NET實例教程建議大家在做注冊表編程調試的時候,采用虛擬機調試 或者備份好本機資料,注冊表一旦破壞或者修改不當可能導致系統(tǒng)崩潰,切記!

【編輯推薦】

  1. 深入分析VB.NET條件語句中的兩類
  2. 五大類VB.NET運算符全面介紹
  3. 全面討論VB.NET申明Windows API函數(shù)
  4. 剖析VB.NET平臺調用是如何執(zhí)行操作
  5. 分享個人總結VB.NET多線程
責任編輯:田樹 來源: 樂博網(wǎng)
相關推薦

2009-10-23 16:00:50

VB.NET實例教程

2009-11-10 16:37:48

VB.NET ANY

2009-10-28 14:13:32

VB.NET File

2009-10-28 14:34:44

VB.NET Tree

2009-11-10 10:28:20

VB.NET誕生

2010-01-19 18:24:29

VB.NET調用Win

2009-11-10 15:36:24

VB.NET命名約定

2010-01-12 13:54:12

VB.NET MDI子

2010-01-11 18:05:24

VB.NET窗體繼承

2009-11-04 11:32:20

VB.NET回調函數(shù)

2009-10-26 16:53:00

VB.NET常用代碼

2009-10-30 10:19:43

VB.NET OBEX

2009-10-29 16:01:54

VB.NET資源文件

2009-10-27 11:39:03

VB.NET事件處理程

2009-11-10 15:30:46

VB.NET編程原則

2009-10-09 17:40:38

VB.Net問題集

2009-10-21 09:40:23

VB.NET搜索

2009-10-22 09:20:46

VB.NET Proc

2010-01-14 13:51:03

2010-01-07 13:51:50

VB.NET數(shù)組賦值
點贊
收藏

51CTO技術棧公眾號