You will need to do the following steps to use this code:
- Click on View at the menu bar.
- Click on Editor from the View’s options.
- Select Register.
These 3 steps will open your deployment project register editor panel, now working with the register panel:
- Expand the HKEY_LOCAL_MACHINE
- Expand the Software node, you should see your project/application name in the next node.
- Select your application name node by clicking on it
Then add an entry here, as follow:
- Right click on your application name node, the one you selected on step 6
- Move the mouse pointer to New, a sub-menu appears.
- Select StringValue
- Assign a name to this new entry, Version will do.
- Then click the Value option at its properties panel on the right.
- Type in the deployment project property (variable) name that hold its version number; which I mentioned above; [ProductVersion]. You should enter it between brackets and remember, it is case sensitive. It will appear like this “[ProductVersion]”, between double quotes.
That’s it, the next time you build and install the project, a register key will be added at: HKEY_LOCAL_MACHINE\SOFTWARE<your_application_name>\Version; it contains your deployment project version number
Dim regVersion As Microsoft.Win32.RegistryKey
Dim strVersion As String
regVersion = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\<our firm name, highly confidential :-) >", False)
Select Case System.Windows.Forms.SystemInformation.ComputerName
Case "Whatever1"
If Not regVersion Is Nothing Then
Me.Text = "Debug Mode (Version: " & regVersion.GetValue("Version") & ")"
Else
Me.Text = "Debug Mode"
End If
Me.txtInputFileName.Text = "INPUT_DEBUG.TXT"
Case "Whatever2"
If Not regVersion Is Nothing Then
Me.Text = "RELEASE Mode (Version: " & regVersion.GetValue("Version") & ")"
Else
Me.Text = "RELEASE Mode"
End If
Me.txtInputFileName.Text = "INPUT.TXT"
Case Else
Throw New Exception("Whatever")
End Select