内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

VB.NET中怎么實現(xiàn)注冊表操作

這篇文章給大家介紹VB.NET中怎么實現(xiàn)注冊表操作,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

成都創(chuàng)新互聯(lián)公司主要從事成都做網(wǎng)站、網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)延邊朝鮮族,十余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792

VB.NET注冊表操作1,返回或創(chuàng)建一個注冊表鍵

  1. Dim Key1 As Microsoft.Win32.
    RegistryKey   

  2. Key1 = My.Computer.Registry.
    CurrentUser '返回當(dāng)前用戶鍵   

  3. Dim Key2 As Microsoft.Win32.
    RegistryKey   

  4. Key2 = Key1.OpenSubKey("northsnow") 
    '返回當(dāng)前用戶鍵下的northsnow鍵   

  5. If Key2 Is Nothing Then   

  6. Key2 = Key1.CreateSubKey("northsnow")
     '如果鍵不存在就創(chuàng)建它   

  7. End If  

VB.NET注冊表操作2,刪除注冊表鍵

  1. Dim Key1 As Microsoft.Win32.
    RegistryKey   

  2. Key1 = My.Computer.Registry.
    CurrentUser '返回當(dāng)前用戶鍵   

  3. Dim Key2 As Microsoft.Win32.
    RegistryKey   

  4. Key2 = Key1.OpenSubKey("northsnow") 
    '返回當(dāng)前用戶鍵下的northsnow鍵   

  5. If Not Key2 Is Nothing Then   

  6. Key1.DeleteSubKey("northsnow")
     '如果鍵不存在就創(chuàng)建它   

  7. End If  

VB.NET注冊表操作3,創(chuàng)建或讀取注冊表項

  1. Dim Key1 As Microsoft.Win32.RegistryKey   

  2. Key1 = My.Computer.Registry.CurrentUser
     '返回當(dāng)前用戶鍵   

  3. Dim Key2 As Microsoft.Win32.RegistryKey   

  4. Key2 = Key1.OpenSubKey("northsnow",
     True) '返回當(dāng)前用戶鍵下的northsnow
    鍵,如果想創(chuàng)建項,必須指定第二個參數(shù)為true   

  5. If Key2 Is Nothing Then   

  6. Key2 = Key1.CreateSubKey("northsnow") 
    '如果鍵不存在就創(chuàng)建它   

  7. End If  

'創(chuàng)建項,如果不存在就創(chuàng)建,如果存在則覆蓋   Key2.SetValue("name", "塞北的雪")   Key2.SetValue("sex", True)   Key2.SetValue("age", 30)
'返回項值   Dim sb As New System.Text.StringBuilder   sb.AppendLine(Key2.GetValue("name"))   sb.AppendLine(Key2.GetValue("sex"))   sb.AppendLine(Key2.GetValue("age"))   MsgBox(sb.ToString)
  1. '查驗?zāi)硞€項是否存在   

  2. If (Key2.GetValue("name")) 
    Is Nothing Then   

  3. MsgBox("no")   

  4. Else   

  5. MsgBox("yes")   

  6. End If  

  1. If (Key2.GetValue("name2")) 
    Is Nothing Then   

  2. MsgBox("no")   

  3. Else   

  4. MsgBox("yes")   

  5. End If   

  6. '輸出   

  7. ' 塞北的雪   

  8. 'True   

  9. '30   

  10. 'yes   

  11. 'no  

VB.NET注冊表操作4,遍歷注冊表

這個也非常簡單,在窗體上放一個按鈕和兩個文本框,添加如下的代碼

  1. Dim sb As New System.Text.StringBuilder 
    '返回遍歷結(jié)果   

  2. Dim sb2 As New System.Text.StringBuilder 
    '返回讀取出錯的注冊表鍵   

  3. Private Sub Button3_Click()Sub Button3_
    Click(ByVal sender As System.Object, 
    ByVal e As System.EventArgs) Handles 
    Button3.Click   

  4. Dim Key1 As Microsoft.Win32.RegistryKey   

  5. Key1 = My.Computer.Registry.CurrentUser 
    '返回當(dāng)前用戶鍵   

  6. If Not Key1 Is Nothing Then   

  7. sb.AppendLine(Key1.Name)   

  8. readValue(Key1)   

  9. readReg(Key1)   

  10. End If   

  11. Me.TextBox1.Text = sb.ToString   

  12. Me.TextBox2.Text = sb2.ToString   

  13. End Sub   

  14. '遍歷注冊表鍵樹   

  15. Private Sub readReg()Sub readReg
    (ByVal r As Microsoft.Win32.RegistryKey)   

  16. If r.SubKeyCount > 0 Then   

  17. Dim keyName() As String   

  18. Dim keyTemp As Microsoft.Win32.RegistryKey   

  19. keyName = r.GetSubKeyNames   

  20. Dim i As Integer   

  21. For i = 0 To keyName.GetLength(0) - 1   

  22. Try   

  23. sb.AppendLine(keyName(i))   

  24. keyTemp = r.OpenSubKey(keyName(i), True)   

  25. readValue(keyTemp)   

  26. readReg(keyTemp)   

  27. Catch ex As Exception   

  28. sb2.AppendLine(keyName(i))   

  29. End Try   

  30. Next   

  31. End If   

  32. End Sub   

  33. '遍歷某鍵下的項   

  34. Private Sub readValue()Sub readValue
    (ByVal r As Microsoft.Win32.RegistryKey)   

  35. If r.ValueCount > 0 Then   

  36. Dim valueName() As String   

  37. Dim i As Integer   

  38. valueName = r.GetValueNames   

  39. For i = 0 To valueName.GetLength(0) - 1   

  40. sb.AppendLine("####")   

  41. sb.Append(r.Name)   

  42. sb.Append("----")   

  43. sb.Append(r.GetValue(valueName(i))
    .ToString)   

  44. Next   

  45. End If   

  46. End Sub 

關(guān)于VB.NET中怎么實現(xiàn)注冊表操作就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

網(wǎng)頁標(biāo)題:VB.NET中怎么實現(xiàn)注冊表操作
網(wǎng)頁網(wǎng)址:http://www.rwnh.cn/article2/jjseoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、動態(tài)網(wǎng)站、網(wǎng)站營銷、網(wǎng)站制作、電子商務(wù)企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司
察哈| 浑源县| 新民市| 崇左市| 东山县| 弋阳县| 水富县| 池州市| 凌云县| 松原市| 灵璧县| 达州市| 金门县| 比如县| 阳信县| 二连浩特市| 屏边| 沁阳市| 德江县| 清水县| 中西区| 安新县| 博白县| 格尔木市| 杭锦后旗| 海阳市| 商水县| 叶城县| 孟村| 萨迦县| 荆州市| 增城市| 衡阳市| 贵定县| 汾阳市| 肇东市| 丹东市| 怀集县| 濮阳市| 庆元县| 平乡县|