2012-11-06 18 views
6

私はClickOnce技術を使って配備された1つのWindowsアプリケーションを持っています。イメージに表示されているアプリケーションのアイコンを変更する方法はありますか?「プログラムの追加と削除」でClickOnceアプリケーションのアイコンを変更する方法はありますか?

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

おかげでたくさん...その私のために働きました。 – ManjuVijayan

+0

素晴らしい...リンクを投稿するのではなく、あなたのために働いていたものを投稿してください:) – Karthik

答えて

2

次のコードは、私はこの問題を解決するために使用するものです。私はスタックオーバーフローの質問Custom icon for ClickOnce application in 'Add or Remove Programs'を使用しました。

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

このソリューションを試しましたが、インストールウィンドウに表示されているイメージは変更されません(オープニングポストのスクリーンショットなど)。誰かにも解決策がありますか? –

+0

どこからコードを呼び出しますか? – HackSlash

関連する問題