阅读注册表项 [英] Reading a Registry Key

查看:89
本文介绍了阅读注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VB.Net读取注册表项。我已经发布了以下代码

我正在使用:

Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _

(" Software \VB和VBA Program Settings \ Mobile Control\SageQuestSetup")

Dim AlertDB As String = CType(DBConnect.GetValue(" ConnectionString")),

String)


Public AlertConnectionString As String = AlertDB


我已经改变了关键路径并继续获得没有分配给

DBConnect。


我在这里做错了什么?


谢谢


还有更多要设置的变量吗?

I''m trying to read a registry key using VB.Net. I have posted the code below
that I''m using:

Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile Control\SageQuestSetup")
Dim AlertDB As String = CType(DBConnect.GetValue("ConnectionString"),
String)

Public AlertConnectionString As String = AlertDB

I''ve vaildated the key path and I continue to get nothing assigned to
DBConnect.

What am I doing wrong here?

Thanks

Are there more variables to set?

推荐答案




昏暗myReg As RegistryKey = Registry.LocalMachine


Dim MyRegKey As RegistryKey


Dim MyVal As String


MyRegKey = myReg.OpenSubKey(" Software\Microsoft \ Windows NT \ CurrentVersion")


MyVal = MyRegKey.GetValue(" ProductID")

Trace.WriteLine(MyRegKey.GetValue(" ProductID"))


Trace.WriteLine(MyRegKey.GetValue(" RegisteredOwner"))

MyRegKey.Close()


Ken


----------------------------------


" Larry Bird" <拉******* @ discussions.microsoft.com>在消息中写道

新闻:A9 ********************************** @ microsof t.com ...

我正在尝试使用VB.Net读取注册表项。我已经发布了以下代码

我正在使用:

Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _

(" Software \VB和VBA Program Settings \ Mobile Control\SageQuestSetup")

Dim AlertDB As String = CType(DBConnect.GetValue(" ConnectionString")),

String)


Public AlertConnectionString As String = AlertDB


我已经改变了关键路径并继续获得没有分配给

DBConnect。


我在这里做错了什么?


谢谢


是否还有更多变量要设置?
Hi,

Dim myReg As RegistryKey = Registry.LocalMachine

Dim MyRegKey As RegistryKey

Dim MyVal As String

MyRegKey = myReg.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion")

MyVal = MyRegKey.GetValue("ProductID")

Trace.WriteLine(MyRegKey.GetValue("ProductID"))

Trace.WriteLine(MyRegKey.GetValue("RegisteredOwner "))

MyRegKey.Close()

Ken

----------------------------------

"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I''m trying to read a registry key using VB.Net. I have posted the code below
that I''m using:

Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile Control\SageQuestSetup")
Dim AlertDB As String = CType(DBConnect.GetValue("ConnectionString"),
String)

Public AlertConnectionString As String = AlertDB

I''ve vaildated the key path and I continue to get nothing assigned to
DBConnect.

What am I doing wrong here?

Thanks

Are there more variables to set?


我尝试了你提供的代码,我仍然得到相同的结果。

这里有什么我不想要的吗?


我正在进一步阅读并遇到有关权限的问题。可能

这是问题吗?


谢谢


" Ken Tucker [MVP]"写道:
I tried the code that you provided and I''m still getting the same results.
Could there something else I''m missing here?

I was reading further and ran across something about permissions. could
this be the problem?

Thanks

"Ken Tucker [MVP]" wrote:


Dim myReg As RegistryKey = Registry.LocalMachine

Dim MyRegKey As RegistryKey

/>将MyVal作为字符串调暗

MyRegKey = myReg.OpenSubKey(" Software\Microsoft \ Windows NT \ CurrentVersion")

MyVal = MyRegKey.GetValue(" ; ProductID")

Trace.WriteLine(MyRegKey.GetValue(" ProductID"))

Trace.WriteLine(MyRegKey.GetValue(" RegisteredOwner"))

MyRegKey.Close()

Ken

--------------------- -------------

拉里伯德 <拉******* @ discussions.microsoft.com>在消息中写道
新闻:A9 ********************************** @ microsof t.com。 ..
我正在尝试使用VB.Net读取注册表项。我已经发布了以下代码
我正在使用:

Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _
(Software \VB和VBA Program设置\ Mobile Control \SageQuestSetup")
Dim AlertDB As String = CType(DBConnect.GetValue(" ConnectionString"),
String)

Public AlertConnectionString As String = AlertDB

我已经解决了关键路径,我继续没有分配给
DBConnect。

我在这里做错了什么?

谢谢

是否还有更多变量要设置?
Hi,

Dim myReg As RegistryKey = Registry.LocalMachine

Dim MyRegKey As RegistryKey

Dim MyVal As String

MyRegKey = myReg.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion")

MyVal = MyRegKey.GetValue("ProductID")

Trace.WriteLine(MyRegKey.GetValue("ProductID"))

Trace.WriteLine(MyRegKey.GetValue("RegisteredOwner "))

MyRegKey.Close()

Ken

----------------------------------

"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I''m trying to read a registry key using VB.Net. I have posted the code below
that I''m using:

Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile Control\SageQuestSetup")
Dim AlertDB As String = CType(DBConnect.GetValue("ConnectionString"),
String)

Public AlertConnectionString As String = AlertDB

I''ve vaildated the key path and I continue to get nothing assigned to
DBConnect.

What am I doing wrong here?

Thanks

Are there more variables to set?



拉里,


只是来自我鼻子前的一个程序。 (一点点改变)


进口Microsoft.Win32


Dim Reg As RegistryKey = Registry.CurrentUser

Reg = Registry.CurrentUser.CreateSubKey(" Software\FromMe \ ThePart")

Me.ClientSize = New System.Drawing.Size(Reg.GetValue(" Width",100) ,

Reg.GetValue(Height,100))


我希望这有帮助吗?


Cor
Larry,

Just from a program before my nose. (a very little bit changed)

Imports Microsoft.Win32

Dim Reg As RegistryKey = Registry.CurrentUser
Reg = Registry.CurrentUser.CreateSubKey("Software\FromMe \ThePart")
Me.ClientSize = New System.Drawing.Size(Reg.GetValue("Width",100),
Reg.GetValue("Height",100))

I hope this helps?

Cor


这篇关于阅读注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆