|
|
Code Samples
The product includes numerous VB.NET and C# sample applications. All
samples include complete source code. For more detailed sample code please
refer to the sample applications.
Exporting a Registry Key
Listing 1 demonstrates exporting a registry key.
Keys can either be exported in regedit compatible format
or as XML.
' Open the registry key to export
Dim RegistryKey registryKey As RegistryKey
registryKey = RegistryHelper.OpenKey("HKEY_LOCAL_MACHINE\Software\Test")
' Export a registry key and all its contents to a regedit compatible file
RegistryXmlExporter.ExportFile(registryKey, "myreg.reg")
' Export a registry key and all its contents to an XML file
RegistryExporter.ExportFile(registryKey, "myreg.xml")
|
Listing 1 Exporting a registry key
Importing a Registry Key
Listing 2 demonstrates importing a registry key.
Keys can either be imported in regedit compatible format
or as XML.
' Import a registry key and all its contents from a regedit compatible file
RegistryXmlImporter.ImportFile("myreg.reg")
' Import a registry key and all its contents from an XML file
RegistryImporter.ImportFile("myreg.xml")
|
Listing 2 Importing a registry key
Searching a Registry
Listing 3 demonstrates searching a registry for a.
Keys can either be imported in regedit compatible format
or as XML.
Private registrySearcher As RegistrySearcher
Private Sub StartSearch()
Try
registrySearcher = New RegistrySearcher(KeyNameTextBox.Text, _
SearchExpressionTextBox.Text)
registrySearcher.IncludeKeys = KeysCheckBox.Checked
registrySearcher.IncludeValues = ValuesCheckBox.Checked
registrySearcher.IncludeData = DataCheckBox.Checked
AddHandler registrySearcher.Searching, AddressOf OnSearching
AddHandler registrySearcher.Matched, AddressOf OnMatch
AddHandler registrySearcher.Completed, AddressOf OnCompleted
registrySearcher.SynchronizingObject = Me
registrySearcher.EnableRaisingEvents = True
End Sub
Private Sub OnSearching(ByVal sender As Object, _
ByVal e As RegistrySearchEventArgs)
Dim keyCurrentSearching As String
keyCurrentSearching = e.KeyName
' Process search progress events
End Sub
Private Sub OnMatch(ByVal sender As Object, _
ByVal e As RegistryMatchEventArgs)
' Process match found event
Select Case e.MatchType
Case MatchType.KeyMatch
' Key name match
Case MatchType.ValueMatch
' Value name match
Case MatchType.DataMatch
' Value data match
End Select
End Sub
Private Sub OnCompleted(ByVal sender As Object, _
ByVal e As EventArgs)
' Process search complete event
End Sub
|
Listing 3 Searching a Registry
|