problem: wirting to registry

pete69

Member
Joined
Sep 2, 2003
Messages
5
hi@all!

i dont know whats wrong, the error is: "object reference is not set to an instance of an object"

Code:
  Dim key As Microsoft.Win32.RegistryKey

    Dim sKey As String = "Software\Microsoft\Windows NT\Current Version\Print\Acrobat Distiller"
    Dim sEntry As String = "Port"
    Dim sValue As String = "d:\*.pdf"
    Dim temp As String


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        key = Registry.LocalMachine.OpenSubKey(sKey, True)
        key.SetValue(sEntry, sValue)
        key.Close()
      
    End Sub

but isnt my variable key an instance of Microsoft.Win32.RegistryKey?

hope u can help me out here

thx in advance
 
What line does it fail on? Are you sure that you point it to the right registry path because that code works, and the exception you get is thrown when there is no path like the one you specify.
 
hi there!

key was always nothing cuz my Registry-String wasnt correct :-\

it should be "....\CurrentVersion\..." (i am with stupid) ;)

thx for your reply!
 
Back
Top