使用VB写入Registery [英] Writing to Registery using VB

查看:111
本文介绍了使用VB写入Registery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我正在尝试将值写入注册表,到目前为止没有成功

我试图在新的注册表配置单元中将值True写入REG_SZ
到目前为止,这是我的代码:

Hello everyone :)

I''m Trying to write a value into the registry with no success so far

im trying to write the value True to REG_SZ in a new registery hive
heres my code so far:

My.Computer.Registry.CurrentUser.CreateSubKey("Software\Real_Estate_Program")
My.Computer.Registry.CurrentUser.SetValue("Software\Real_Estate_Program", "REG_SZ", RegistryValueKind.String)
My.Computer.Registry.CurrentUser.SetValue("c", "True")
Console.WriteLine(My.Computer.Registry.CurrentUser.GetValue("Software\Real_Estate_Program\REG_SZ"))
Console.ReadLine()



如果有人指出我的错误所在,我将不胜感激.

提前通知您,tsahi.



I''ll be thankfull if some 1 will point where''s my mistake.

Thenk you in advance, tsahi.

推荐答案

试试看.
http://msdn.microsoft.com/en-us/library/cy6azwf7 (v = vs.80).aspx [
try this.
http://msdn.microsoft.com/en-us/library/cy6azwf7(v=vs.80).aspx[^]


REG_SZ是注册表中的字符串值.

使用
REG_SZ is a string value in the registry.

Use
My.Computer.Registry.CurrentUser.SetValue("Software\Real_Estate_Program", "c", "True")




or

My.Computer.Registry.CurrentUser.SetValue("Software\Real_Estate_Program", "c", "True", RegistryValueKind.String)


在第一个调用中,
SetValue [ RegistryValueKind.String [ SetValue [


In the first call the SetValue[^] determines that the value needs to be stored as a REG_SZ, because you are passing the value as a string.
The RegistryValueKind.String[^] enum in the second call tells the SetValue[^] function you want to store the value as a REG_SZ.

To retrieve this value from the registry use

My.Computer.Registry.CurrentUser.GetValue("Software\Real_Estate_Program\", "c", "default")


当您要检索的键不存在时,该函数将返回GetValue调用中的最后一个参数.


The last parameter in the GetValue call is returned by the function when the key you are retrieving does not exist.


这篇关于使用VB写入Registery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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