469,898 Members | 1,586 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Registry

How do you write a new Reg_Expand_sz value to the resgistry with vb.net
this used to work when you pad the string with a null.

Anyone know how or what i'm doing wrong ? It just writes a new Reg_sz value
to the reg.

Dim rk2 As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("Software\RegTest\")
rk2.SetValue("Stuff vb.net expanded string", New System.String("%PATH%" &
Microsoft.VisualBasic.vbNullChar))

rk2.Close()


Nov 21 '05 #1
3 3426
First of all, are you getting some error?

Secondly, the RegistryKey class writes strings as sz only. If the value was
originally definined as expand_sz, it will retain that flag, but you cannot
control that from the .NET class. In either case, the value will always
contain the unexpanded path, so you'll always have to use
Environment.ExpandEnvironmentVariables on the value to property read it.

-Rob Teixeira

"David Gacek" <so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How do you write a new Reg_Expand_sz value to the resgistry with vb.net
this used to work when you pad the string with a null.

Anyone know how or what i'm doing wrong ? It just writes a new Reg_sz value to the reg.

Dim rk2 As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("Software\RegTest\")
rk2.SetValue("Stuff vb.net expanded string", New System.String("%PATH%" &
Microsoft.VisualBasic.vbNullChar))

rk2.Close()

Nov 21 '05 #2
what i want to do is create a new Expandable string value in the registry
with vb.net i am not getting an error .
Can this be done with vb.net? and if so how.?
"Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
First of all, are you getting some error?

Secondly, the RegistryKey class writes strings as sz only. If the value was originally definined as expand_sz, it will retain that flag, but you cannot control that from the .NET class. In either case, the value will always
contain the unexpanded path, so you'll always have to use
Environment.ExpandEnvironmentVariables on the value to property read it.

-Rob Teixeira

"David Gacek" <so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How do you write a new Reg_Expand_sz value to the resgistry with vb.net
this used to work when you pad the string with a null.

Anyone know how or what i'm doing wrong ? It just writes a new Reg_sz

value
to the reg.

Dim rk2 As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("Software\RegTest\")
rk2.SetValue("Stuff vb.net expanded string", New System.String("%PATH%" & Microsoft.VisualBasic.vbNullChar))

rk2.Close()


Nov 21 '05 #3
So when i open the registry editor i can see that it created a new
Expandable string value.
I can create all the other types of values expect for the one in question.

Thanks
"David Gacek" <so*****@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
what i want to do is create a new Expandable string value in the registry
with vb.net i am not getting an error .
Can this be done with vb.net? and if so how.?
"Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
First of all, are you getting some error?

Secondly, the RegistryKey class writes strings as sz only. If the value was
originally definined as expand_sz, it will retain that flag, but you

cannot
control that from the .NET class. In either case, the value will always
contain the unexpanded path, so you'll always have to use
Environment.ExpandEnvironmentVariables on the value to property read it.

-Rob Teixeira

"David Gacek" <so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How do you write a new Reg_Expand_sz value to the resgistry with vb.net this used to work when you pad the string with a null.

Anyone know how or what i'm doing wrong ? It just writes a new Reg_sz

value
to the reg.

Dim rk2 As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("Software\RegTest\") rk2.SetValue("Stuff vb.net expanded string", New
System.String("%PATH%" & Microsoft.VisualBasic.vbNullChar))

rk2.Close()



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rohit Santhanam | last post: by
1 post views Thread by rdavis7408 | last post: by
8 posts views Thread by Al Kaufman | last post: by
4 posts views Thread by Bob | last post: by
3 posts views Thread by eSolTec, Inc. 501(c)(3) | last post: by
3 posts views Thread by Aussie Rules | last post: by
6 posts views Thread by JOSII | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.