扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:马金虎 来源:yesky 2007年11月10日
关键字:
Dim hklm As RegistryKey = Registry.LocalMachine Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ) '打开"SYSTEM"子健 Dim software As RegistryKey = software11.OpenSubKey ( "A000" ) '打开"A000"子健 |
OpenSubKey ( 子健名称 , true ) |
listBox1.Items.Clear ( ) Dim hklm As RegistryKey = Registry.LocalMachine '打开"SYSTEM"子健 Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ,true ) '打开"A000"子健 Dim software As RegistryKey = software11.OpenSubKey ( "A000" , true ) Dim ddd As RegistryKey = software.CreateSubKey ( "ddd" ) ddd.SetValue ( "www" , "1234" ) |
Imports System Imports System.Drawing Imports System.ComponentModel Imports System.Windows.Forms Imports Microsoft.Win32 '导入程序中使用的名称空间 Public Class Form1 Inherits Form Public Sub New ( ) MyBase.New ( ) '初始化窗体中的各个组件 InitializeComponent ( ) End Sub '清除程序中使用过的各种资源 Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean ) If disposing Then If Not ( components Is Nothing ) Then components.Dispose ( ) End If End If MyBase.Dispose ( disposing ) End Sub Friend WithEvents Button1 As Button Friend WithEvents listBox1 As ListBox Friend WithEvents Button2 As Button Friend WithEvents Button3 As Button Private components As System.ComponentModel.Container '初始化程序中使用到的组件 Private Sub InitializeComponent ( ) Me.listBox1 = New ListBox ( ) Me.Button1 = New Button ( ) Me.Button2 = New Button ( ) Me.Button3 = New Button ( ) Me.SuspendLayout ( ) Me.listBox1.ItemHeight = 12 Me.listBox1.Location = New Point ( 8 , 24 ) Me.listBox1.Name = "listBox1" Me.listBox1.Size = New Size ( 480 , 292 ) Me.listBox1.TabIndex = 1 ...下略 Me.Controls.Add ( Me.listBox1 ) Me.Controls.Add ( Me.Button1 ) Me.Controls.Add ( Me.Button2 ) Me.Controls.Add ( Me.Button3 ) Me.Name = "Form1" Me.Text = "用VB.NET进行注册表编程!" Me.ResumeLayout ( False ) End Sub Private Sub Button1_Click ( ByVal sender As System.Object , ByVal e As System.EventArgs ) _ Handles Button1.Click listBox1.Items.Clear ( ) Dim hklm As RegistryKey = Registry.LocalMachine Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ) '打开"SYSTEM"子健 Dim software As RegistryKey = software11.OpenSubKey ( "A000" ) '打开"A000"子健 Dim KeyCount As integer = software.SubKeyCount '获得当前健下面有多少子健 Dim Str ( ) As String = software.GetSubKeyNames ( ) '获得当前健下面所有子健组成的字符串数组 Dim i As integer For i = 0 to KeyCount - 1 listBox1.Items.Add ( Str ( i ) ) Dim sitekey As RegistryKey = software.OpenSubKey ( Str ( i ) ) '按顺序打开子健 Dim Str2 ( ) As String = sitekey.GetValueNames ( ) '获得当前子健下面所有健组成的字符串数组 Dim ValueCount As integer = sitekey.ValueCount '获得当前子健存在多少健值 Dim j As integer For j = 0 to ValueCount - 1 listBox1.Items.Add ( " " + Str2 ( j ) + ": " + sitekey.GetValue ( Str2 ( j ) ) ) '在列表中加入所有子健、健和健值 Next j Next i End Sub '创建子健,并创建一个健并赋值 Private Sub Button2_Click ( ByVal sender As System.Object , ByVal e As System.EventArgs ) _ Handles Button2.Click listBox1.Items.Clear ( ) Dim hklm As RegistryKey = Registry.LocalMachine '打开"SYSTEM"子健 Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ,true ) '打开"A000"子健 Dim software As RegistryKey = software11.OpenSubKey ( "A000" , true ) Dim ddd As RegistryKey = software.CreateSubKey ( "ddd" ) ddd.SetValue ( "www" , "1234" ) End Sub '重命名一个健的值 Private Sub Button3_Click ( ByVal sender As System.Object , ByVal e As System.EventArgs ) _ Handles Button3.Click listBox1.Items.Clear ( ) Dim hklm As RegistryKey = Registry.LocalMachine '打开"SYSTEM"子健 Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ,true ) '打开"A000"子健 Dim software As RegistryKey = software11.OpenSubKey ( "A000" , true ) Dim ddd As RegistryKey = software.CreateSubKey ( "ddd" ) ddd.SetValue ( "www" , "aaaa" ) End Sub End Class Module Module1 Sub Main ( ) Application.Run ( New Form1 ( ) ) End Sub End Module |
图03:用VB.NET创建和修改注册表程序运行界面 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者