रजिस्ट्री को संपादित किए बिना ऐसा करने का कोई तरीका नहीं है, लेकिन आप इसे प्रोग्रामेटिक रूप से कर सकते हैं। आपको यह सुनिश्चित करना होगा कि आइकन तैनाती में शामिल है। हमने अपने असेंबली विवरण को हमारे उत्पाद नाम के समान स्ट्रिंग पर सेट किया है, इसलिए हम असेंबली विवरण की खोज करके सही एप्लिकेशन के लिए अनइंस्टॉल स्ट्रिंग को देख सकते हैं। इस तरह, हमें इस कोड में उत्पाद का नाम हार्डकोड करने की आवश्यकता नहीं है।
private static void SetAddRemoveProgramsIcon()
{
//only run if deployed
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed
&& ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
try
{
Assembly code = Assembly.GetExecutingAssembly();
AssemblyDescriptionAttribute asdescription =
(AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code, typeof(AssemblyDescriptionAttribute));
string assemblyDescription = asdescription.Description;
//the icon is included in this program
string iconSourcePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "youriconfile.ico");
if (!File.Exists(iconSourcePath))
return;
RegistryKey myUninstallKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
string[] mySubKeyNames = myUninstallKey.GetSubKeyNames();
for (int i = 0; i < mySubKeyNames.Length; i++)
{
RegistryKey myKey = myUninstallKey.OpenSubKey(mySubKeyNames[i], true);
object myValue = myKey.GetValue("DisplayName");
if (myValue != null && myValue.ToString() == assemblyDescription)
{
myKey.SetValue("DisplayIcon", iconSourcePath);
break;
}
}
}
catch (Exception ex)
{
//log an error
}
}
}
संबंधित: * [ 'प्रोग्राम जोड़ें या निकालें' में ClickOnce आवेदन के लिए चिह्न] (http://stackoverflow.com/questions/13265806/) * –