Shimul, my friend, suggested me to add some advanced feature of creating setup project like registry key. This blog contains basic steps of adding a registry key from setup project as well as reading a registry key value from the program.
How to see the registry keys:
Click on Start Menu > Run > regedit [enter]. Here you will see the following.
You can find a short description on registry key here http://www.dotnetheaven.com/Uploadfile/sushmita_kumari/RegistryKeys102212006232904PM/RegistryKeys1.aspx
How to Add Registry Keys from Setup Project:
- In Solution Explorer, right click on Setup Project.
- Click on View > Registry.
- Expand the tree view of Registry key (setup) in the left side where you want to add a key. Here we will add a key in following directory.
- Right click on [Manufacturer] > New > String Value.
- Rename the newly added key name. Set its value from it’s properties.
How to modify Manufacturer:
Sample Code to Read Registry Key:
using Microsoft.Win32;
string v = getRegistryKeyValue(@"SOFTWARE\BUET", "MyKey");
MessageBox.Show("Key value : " + v);
private string getRegistryKeyValue(string keyPath, string keyName)
{
try
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey(keyPath);
string s = (string)(rk.GetValue(keyName));
rk.Close();
return s;
}
catch (Exception ex)
{
return null;
}
}
3 Comments:
thanks buddy :)
i want to add an uninstall link in the User's Program Menu, can you help me with this?
This is an awesome post. Figured it out.
Post a Comment