Setting a registry value based on dialog in a visual studio setup project

1k views Asked by At

I have visual studio setup project with a custom RadioButtons dialog.

How do I get it to write the value of the ButtonProperty in the registry after it is selected in the UI?

1

There are 1 answers

0
Sam Saffron On BEST ANSWER

If using a .Net Installer class do the following:

  1. Pipe the data through to your Custom Action using CustomActionData eg: If your property is called MYPROP: /MyVar=[MYPROP]

  2. You can now access the data from your installer class:

    protected override void OnAfterInstall(IDictionary savedState) {
    
            string myVar = Context.Parameters["MyVar"];
            RegistryKey key = Registry.LocalMachine;
            using (key = key.CreateSubKey(@"SOFTWARE\MyCompany\MyApp")) {
                key.SetValue("MyVar", myvar);
                key.Close();
            }
    }