2012-11-06 11 views
6

Ich habe eine Windows-Anwendung, die mit ClickOnce Technologie bereitgestellt wird. Gibt es eine Möglichkeit, das Symbol der Anwendung, die im Bild angezeigt wird, zu ändern?Gibt es eine Möglichkeit, das Symbol einer ClickOnce-Anwendung in "Programme hinzufügen oder entfernen" zu ändern?

Screenshot of the installer in action with a marker for the icon.

+2

http://stackoverflow.com/questions/10927109/icon-for-click-once-app-in-add-or-remove-programs – Karthik

+0

Thanks a lot .. Sein für mich gearbeitet. – ManjuVijayan

+0

Great..Post was für Sie gearbeitet hat, anstatt den Link zu posten .. :) – Karthik

Antwort

2

Der folgende Code ist, was ich für die Lösung des Problems verwendet. Ich habe Stack Overflow Frage Custom icon for ClickOnce application in 'Add or Remove Programs' verwendet.

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, "hl772-2.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() == "admin") 
        { 
         myKey.SetValue("DisplayIcon", iconSourcePath); 
         break; 
        } 
       } 
      } 
      catch (Exception ex) 
      { 
       System.Windows.Forms.MessageBox.Show(ex.Message.ToString()); 
      } 
     } 
    } 
+0

Ich habe diese Lösung versucht, aber es ändert nicht das Bild im Installationsfenster angezeigt (wie im Screenshot des Eröffnungsbeitrags). Hat jemand dafür auch eine Lösung? –

+0

Woher nennst du diesen Code? – HackSlash