0

I have written a PowerPoint addin using Visual Studion 2012.

I had never done this before and started the project from File / New / powerpoint 2010 addin.

This created a "class library" project.

So I wrote my addin and it works perfectly. Happy Days!

But, when the application is installed on a computer the icon in Control Panel / Installed Software is a default icon.

Normally, I would have expected to be able to go into Project Properties / Application and select the icon there that I wanted to use but the only option I have is to choose a resource file.

I have added the .ico file to my resource but just cannot seem to work out how to make it the icon for the project.

Can anyone help please?

Sorry, forgot to say, this is being installed using the "ClickOnce" distribution system. I have looked at the "Publish" properties tab and there is nothing in there to define the application icon either.

Thanks

Trevor

Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89

2 Answers2

1

Ok, now that I know ClickOnce is involved, I think you can find useful this peice of code. It has to run when the application starts. The code edits the registry directly, so probably it could be different in some Windows versions.

/// <summary>
/// change the icon in add/remove programs     
/// </summary>
private static void SetProgramInstallIcon()
{
  //run only when deployed 
  if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed
     && ApplicationDeployment.CurrentDeployment.IsFirstRun)
  {
    try
    {
      string iconSourcePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "YourFancyIcon.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() == "YourApplicationDisplayName")
        {
          myKey.SetValue("DisplayIcon", iconSourcePath);
          break;
        }
      }
    }
    catch (Exception ex) {
      //manage errors as you like (log, UI, ...)
    }
  }
}
br1
  • 313
  • 1
  • 10
  • this does look like a possible solution but im wary of implementing it because of the registry differences you mention? thanks!! – Trevor Daniel Aug 06 '13 at 18:33
0

It looks like this is not possible from what this thread says....

as it's a .dll the OS decides what icon to allocate to it.

Trev

Add Icon to Visual Studio 2008-Built Class Lib DLL?

Community
  • 1
  • 1
Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89
  • I think that thread is talking about the file icon, not the icon inside the Control Panel / Installed Software menu. – br1 Aug 06 '13 at 11:08