Nie można tego zrobić bez edytowania rejestru, ale można to zrobić programowo. Musisz mieć pewność, że ikona jest dołączona do wdrożenia. Ustawiamy nasz opis montażu na taki sam ciąg, jak nazwa naszego produktu, dzięki czemu możemy przeglądać ciągi deinstalacji dla odpowiedniej aplikacji, wyszukując opisu zespołu. W ten sposób nie musimy kodować nazwy produktu w tym kodzie.
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
}
}
}
pokrewne: * [Ikona aplikacji ClickOnce w 'Dodaj lub usuń programy'] (http://stackoverflow.com/questions/13265806/) * –