' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Windows.Forms

Imports Microsoft.Win32

Namespace E
    Public Class MainForm
        Inherits Form
        Private label1 As Label
        Private label2 As Label
        Private textBox1 As TextBox
        Private textBox2 As TextBox
        Private button1 As Button

        Public Shared Sub Main
            Dim fMainForm As New MainForm
            fMainForm.ShowDialog()
        End Sub
        Public Sub New()
            MyBase.New
            InitializeComponent
        End Sub
        Private Sub InitializeComponent()
            label1 = New Label
            label2 = New Label
            textBox2 = New TextBox
            textBox1 = New TextBox
            button1 = New Button
            SuspendLayout
            label1.Location = New Point(25, 25)
            label1.Size = New Size(60, 20)
            label1.Text = "Software"
            label2.Location = New Point(25, 75)
            label2.Size = New Size(60, 20)
            label2.Text = "Filename"
            textBox1.Location = New Point(100, 25)
            textBox1.Size = New Size(120, 20)
            textBox2.Location = New Point(100, 75)
            textBox2.Size = New Size(120, 20)
            button1.Location = New Point(25, 125)
            button1.Size = New Size(195, 20)
            button1.Text = "Dump"
            AddHandler button1.Click, AddressOf Button1Click
            ClientSize = New Size(245, 175)
            Controls.Add(label1)
            Controls.Add(label2)
            Controls.Add(textBox1)
            Controls.Add(textBox2)
            Controls.Add(button1)
            Text = "Software Dumper"
            ResumeLayout(false)
        End Sub
        Private Shared Sub Dump(ByVal sw As StreamWriter, ByVal key As RegistryKey)
            Dim subkeys As String() = key.GetSubKeyNames
            For Each sk As String In subkeys
                Dump(sw, key.OpenSubKey(sk))
            Next
            Dim vals As String() = key.GetValueNames
            For Each v As String In vals
                Dim data As String = key.GetValue(v).ToString
                sw.WriteLine(key.Name & "\" & v & "=" & data)
            Next
        End Sub
        Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
            Dump(New StreamWriter(textBox2.Text), Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey(textBox1.Text))    
        End Sub
    End Class
End Namespace
