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

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

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

+3
source share
1 answer

If you are using the .Net Installer class, follow these steps:

  • Connect the data to your custom action using CustomActionData, for example: If your property is called MYPROP: /MyVar=[MYPROP]

  • Now you can 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();
            }
    }
    
+3
source

Source: https://habr.com/ru/post/1740097/


All Articles