独自幸福快乐吴胜直言队伍进攻点单一浙江女排迎来四连败依依不舍孤独

文章来源:中山文学网  |  2020-06-17

中访问注册表变得非常的简单。我们可以用n32 名称空间的下的registry类和registryKey类。另外gistry 也可以返回一个gistry类的实例。

下面就举几个小例子来说明访问注册表的方法。

1、返回或创建一个注册表键

Dim Key1 As gistryKey

Key1 = rrentUser ''返回当前用户键

Dim Key2 As gistryKey

Key2 = enSubKey("northsnow") ''返回当前用户键下的northsnow键

If Key2 Is Nothing Then

Key2 = eateSubKey("northsnow") ''如果键不存在就创建它

End If

2、删除注册表键

Dim Key1 As gistryKey

Key1 = rrentUser ''返回当前用户键

Dim Key2 As gistryKey

Key2 = enSubKey("northsnow") ''返回当前用户键下的northsnow键

If Not Key2 Is Nothing Then

leteSubKey("northsnow") ''如果键不存在就创建它

End If

3、创建或读取注册表项

Dim Key1 As gistryKey

Key1 = rrentUser ''返回当前用户键

Dim Key2 As gistryKey

Key2 = enSubKey("northsnow", True) ''返回当前用户键下的northsnow键,

如果想创建项去的也快,必须指定第二个参数为true

If Key2 Is Nothing Then

Key2 = eateSubKey("northsnow") ''如果键不存在就创建它

End If

''创建项,如果不存在就创建,如果存在则覆盖

tValue("name"络形式缓解年夜饭困境, "塞北的雪")

tValue("sex", True)

tValue("age", 30)

''返回项值

Dim sb As New ringBuilder

pendLine(tValue("name"))

pendLine(tValue("sex"))

pendLine(tValue("age"))

MsgBox(String)

''查验某个项是否存在

If (tValue("name")) Is Nothing Then

MsgBox("no")

Else

MsgBox("yes")

End If

If (tValue("name2")) Is Nothing Then

MsgBox("no")

Else

MsgBox("yes")

End If

''输出

'' 塞北的雪

''True

''30

''yes

''no

4、遍历注册表

这个也非常简单,在窗体上放一个按钮和两个文本框,添加如下的代码:

Dim sb As New ringBuilder ''返回遍历结果

Dim sb2 As New ringBuilder ''返回读取出错的注册表键

Private Sub Button3_Click()Sub Button3_Click(ByVal sender As ject,

ByVal e As entArgs) Handles ick

Dim Key1 As gistryKey

Key1 = rrentUser ''返回当前用户键

If Not Key1 Is Nothing Then

pendLine()

readValue(Key1)

readReg(Key1)

End If

xt = String

xt = String

End Sub

''遍历注册表键树

Private Sub readReg()Sub readReg(ByVal r As gistryKey)

If bKeyCount 0 Then

Dim keyName() As String

Dim keyTemp As gistryKey

keyName = tSubKeyNames

Dim i As Integer

For i = 0 To tLength(0) - 1

Try

pendLine(keyName(i))

keyTemp = enSubKey(keyName(i), True)

readValue(keyTemp)

readReg(keyTemp)

Catch ex As Exception

pendLine(keyName(i))

End Try

Next

End If

End Sub

''遍历某键下的项

Private Sub readValue()Sub readValue(ByVal r As gistryKey)

If lueCount 0 Then

Dim valueName() As String

Dim i As Integer

valueName = tValueNames

For i = 0 To tLength(0) - 1

pendLine("####")

pend()

pend("----")

pend(tValue(valueName(i)).ToString)

Next

End If

End Sub

宝宝积食消化不良怎么办
慢性心律失常危害
贵港白癜风
友情链接