Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Windows and Controls Code Examples

Importing and Exporting sections of the registry to a .reg file

Importing and Exporting sections of the registry to a .reg file Below are two useful routines to import and export sections of the registry to a ".reg" file. Note, a demonstration routine can be found at the bottom of this article. Option Explicit 'Purpose : Exports a section of the registry to a .reg file 'Inputs : sKey The registry key to export. ' sFilename The file name to export the registry file to. 'Outputs : N/A 'Notes : Uses commandline variables to call Regedit.exe Sub RegeditExport(sKey As String, sFilename As String) Shell "regedit.exe /s /e " & Chr(34) & sFilename & Chr(34) & " " & Chr(34) & sKey & Chr(34), vbHide End Sub 'Purpose : Imports a windows registry file (.reg) to the registry. 'Inputs : sFilename The path and file name of the file to import. 'Outputs : N/A 'Notes : Uses commandline variables to call Regedit.exe Sub RegeditImport(sFilename As String) Shell "regedit.exe /s /c " & Chr(34) & sFilename & Chr(34), vbHide End Sub 'Demonstration routine Sub Test() 'Export a section from the VB and VBA program settings to a file RegeditExport "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\VBusersFTP\Connections", "C:\FTP Settings.reg" 'Import this section back in RegeditImport "C:\FTP Settings.reg" End Sub