Question Exporting registry keys...

Vrushank

New member
Joined
Dec 14, 2008
Messages
2
Programming Experience
1-3
How do you export registry entries to a .reg file? I mean like giving the user the option to backup registry changes before continuing... :eek:

Please tell me the EXACT syntax for the available commands since the ones I found on the internet were not precise... :mad
 
Done... but with errors .... :(

OK I tried doing the above using for loops to read each subkey, its value name and the corresponding value. Here's the code :

PHP:
 Dim autoshell As Microsoft.Win32.RegistryKey
        Dim l As Microsoft.Win32.RegistryValueKind
        Try
            autoshell = Registry.CurrentUser.OpenSubKey("TEST", True)
            Dim vals(), v As String
            Dim s As Object
            vals = autoshell.GetValueNames()
            v = ""
            For m As Integer = 0 To autoshell.ValueCount() - 1 'print all values
                l = autoshell.GetValueKind(vals(m))
                s = autoshell.GetValue(vals(m))
                Select Case l
                    Case RegistryValueKind.Binary
                        v = vals(m) & "--> Binary " & Convert.ToBase64String(s) & vbNewLine
                    Case RegistryValueKind.DWord
                        v = vals(m) & "--> DWORD " & s & vbNewLine
                    Case RegistryValueKind.ExpandString
                        v = vals(m) & "--> EXP_SZ " & s & vbNewLine
                    Case RegistryValueKind.MultiString
                        v = vals(m) & "--> MUL_SZ " & Convert.ToString(s) & vbNewLine
                    Case RegistryValueKind.String
                        v = vals(m) & "--> REG_SZ " & s & vbNewLine
                End Select
            Next m
            MsgBox(v)
	  Catch ex As ArgumentException
            MsgBox("ERROR. The Key does not exist.", MsgBoxStyle.Exclamation)
        End Try


But now there are 2 problems:

  1. If it encounters a BINARY type, the value of 's' ends up as a byte (which it should be!), but I get an error message that I can't convert Byte to string.
  2. If there is a value of type EXP_SZ or MULTI_SZ, it doesn't read the other values, be it DWORD or String.
  3. Also, as per problem (2), it is displaying only one value in the msgbox inspite of putting the for loop.

Can anyone please rectify my errors and please tell me where I'm going wrong???? :confused:
 

Latest posts

Back
Top