Trevor Daniel
Trevor Daniel

Reputation: 3974

Visual Studio - Application Icon - PowerPoint Addin

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

Upvotes: 0

Views: 514

Answers (2)

br1
br1

Reputation: 313

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, ...)
    }
  }
}

Upvotes: 1

Trevor Daniel
Trevor Daniel

Reputation: 3974

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?

Upvotes: 0

Related Questions