We have a case to create a Setup project for a Windows Forms project in the Visual Studio 2010, we need to write registry key and value when user install our software.
How to Add Registry Key and Value in a Setup Project?
1: Click your Setup project, you will see there is a Registry icon on the top of Solution Explorer window:
Click the icon, a registry window will appear as shown in the screenshot below. for our case, we are going to add key and value under the HKEY_LOCAL_MACHINE\Software node:
Right click on the Software node and select New –> Key to create a new key, you can create multiple sub nodes here;
For a value, you can set it like below. For our case, we need to set a directory, then we select String Value
Because we need the directory to be the same as our software installation directory, we set it as below:
If our Manufacturer = “Our Manufacturer” and ProductName = "Our Product", then the setting above corresponds to the following real path:
"C:\Program Files (x86)\Our Manufacturer\Our Product\Lib\WinForm\SymbolFactory"
Save the setting, rebuild the Setup Project, and try to run the Setup program, now we can see the Setup program can write the Registry key and value.