how do I read and write to the registry ? 
Author Message
 how do I read and write to the registry ?

  PLease can somebody tell me how to write and read entries into the
registry ????

Thanks!!!



Tue, 13 Jul 2004 06:46:54 GMT  
 how do I read and write to the registry ?
The Microsoft.Win32 Namespace has support for reading and writing to the
registry.


Quote:
>   PLease can somebody tell me how to write and read entries into the
> registry ????

> Thanks!!!



Tue, 13 Jul 2004 05:01:46 GMT  
 how do I read and write to the registry ?
Try this:

Dim objReg As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine
Dim objKey As Microsoft.Win32.RegistryKey =
objReg.OpenSubKey("Software\CompanyName\Software", False)  'Adjust
companyname and software as needed
Dim strKeyResult As String
strKeyResult = objKey.GetValue("itemname").ToString  'Adjust itemname as
needed

This will open the registry for "LocalMachine" (first line, can be changed
if needed).


Quote:
>   PLease can somebody tell me how to write and read entries into the
> registry ????

> Thanks!!!



Tue, 13 Jul 2004 06:11:01 GMT  
 how do I read and write to the registry ?
Imports Microsoft.Win32

Dim strDataValue As String
Dim oRegKey As RegistryKey
Dim oBaseKey As RegistryKey

oBaseKey = Registry.CurrentUser
' Get the default User ID and other default settings
oRegKey = oBaseKey.OpenSubKey("Identities", True)
Dim strDefaultUser = CType(oRegKey.GetValue("Default User ID"), String
Dim strLastUser = CType(oRegKey.GetValue("Last User ID"), String)
_strLastUserName = CType(oRegKey.GetValue("Last Username"), String)
oRegKey.Close()

' set the default save path, default is current directory
_strExportPath = "OE5X"
txtDestination.Text = Directory.GetCurrentDirectory & "\" & _strExportPath

Dan


Quote:
>   PLease can somebody tell me how to write and read entries into the
> registry ????

> Thanks!!!



Tue, 13 Jul 2004 10:54:05 GMT  
 how do I read and write to the registry ?
Sam,  I tried this code:

Try
    Dim oBaseKey As RegistryKey = Registry.LocalMachine
    Dim oRegKey As RegistryKey = oBaseKey.OpenSubKey _
("Software/Adobe/Acrobat/4.0/Uninstall", True)
    Dim strStuff = CType(oRegKey.GetValue("AWEInstall"), String)
    oRegKey.Close()
Catch ex As Exception
    TextBox1.Text = ex.ToString
End Try

but I get an error :  System.NullReferenceException: Value null was found
where an instance of an object was required.

What does this error mean?
Do you see what I am doing wrong ?

thank you...............very much


Quote:
> Try this:

> Dim objReg As Microsoft.Win32.RegistryKey =
> Microsoft.Win32.Registry.LocalMachine
> Dim objKey As Microsoft.Win32.RegistryKey =
> objReg.OpenSubKey("Software\CompanyName\Software", False)  'Adjust
> companyname and software as needed
> Dim strKeyResult As String
> strKeyResult = objKey.GetValue("itemname").ToString  'Adjust itemname as
> needed

> This will open the registry for "LocalMachine" (first line, can be changed
> if needed).



> >   PLease can somebody tell me how to write and read entries into the
> > registry ????

> > Thanks!!!



Fri, 23 Jul 2004 21:37:18 GMT  
 how do I read and write to the registry ?
Check the documentation for RegistryKey.OpenSubKey() and RegistryKey.GetValue()...

OpenSubkey and GetValue both return null (aka Nothing) if the key passed to OpenSubKey or the value name passed to GetValue does not exist.  Since you have both method calls in the same Try block, it could be either call.

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> Sam,  I tried this code:

> Try
>     Dim oBaseKey As RegistryKey = Registry.LocalMachine
>     Dim oRegKey As RegistryKey = oBaseKey.OpenSubKey _
> ("Software/Adobe/Acrobat/4.0/Uninstall", True)
>     Dim strStuff = CType(oRegKey.GetValue("AWEInstall"), String)
>     oRegKey.Close()
> Catch ex As Exception
>     TextBox1.Text = ex.ToString
> End Try

> but I get an error :  System.NullReferenceException: Value null was found
> where an instance of an object was required.

> What does this error mean?
> Do you see what I am doing wrong ?

> thank you...............very much



> > Try this:

> > Dim objReg As Microsoft.Win32.RegistryKey =
> > Microsoft.Win32.Registry.LocalMachine
> > Dim objKey As Microsoft.Win32.RegistryKey =
> > objReg.OpenSubKey("Software\CompanyName\Software", False)  'Adjust
> > companyname and software as needed
> > Dim strKeyResult As String
> > strKeyResult = objKey.GetValue("itemname").ToString  'Adjust itemname as
> > needed

> > This will open the registry for "LocalMachine" (first line, can be changed
> > if needed).



> > >   PLease can somebody tell me how to write and read entries into the
> > > registry ????

> > > Thanks!!!



Sat, 24 Jul 2004 09:28:19 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Writing a VBS file which reads and writes to the registry

2. reading and writing to the registry

3. Reading & writing the registry

4. Class to Read/Write any Registry key

5. How I read/write on registry with VBA?

6. Read or Write to Registry

7. Help: read or write to the registry

8. Registry read/write

9. How can I Read-Write the registry from a VBScript-Procedure of an outlook-form

10. How can I Read-Write remote registry

11. Reading/Writing to the Registry and .INI file???

12. How to read/write a key to the registry

 

 
Powered by phpBB® Forum Software