0

From where the clickonce get the value used in DisplayName in the register HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XXXXXXXX ? I tried the change the application title and assembly name on VS(project -> properties -> application -> assembly information) but this neither change there changed the name used in DisplayName value.

I need this because I want to avoid hard-code my application name on this piece of code that change the unistall icon of my application on add/remove programs

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() == applictionName) /* this must be the same used by clickonce to set DisplayName value  */
    {
        myKey.SetValue("DisplayIcon", iconSourcePath);
        break;
    }
}
MethodMan
  • 18,625
  • 6
  • 34
  • 52
Jack
  • 16,276
  • 55
  • 159
  • 284

2 Answers2

1

From where clickonce get the value used in DisplayName from regedit?

To set the display name for a ClickOnce app, you specify it in Publish Options inside Visual Studio prior to publishing. This updates the ClickOnce Manifest - information about the ClickOnce application. This information is more important and essentially veteos any details you may specify in Assembly Information.

<project>.Properties.Publish.Options

enter image description here

Also, there is no need to muck about in the Windows Registry for ClickOnce apps. Doing so may block automatic updates.

  • Thanks. I've looked on public tab and missed out this. Is possible to get this value programatically? – Jack Nov 06 '15 at 21:42
  • Change the ico may block the automatic updates? Must I don't do than then? – Jack Nov 06 '15 at 21:44
  • The info will be in the manifest file where the app is installed. I don't recommend changing it. If you want a different name, change it prior to publishing, then after publishing, clients will update and display a _new name_. –  Nov 06 '15 at 21:48
  • I want to get this programatically to avoid hard-code the application name string in that part `if (myValue != null && myValue.ToString() == "app name")` I don't plan to change the name anytime soon, I just would like to avoid hard-code that. Who knows if the application change the name in some years, the ico will stop working if I don't remeber to change that string – Jack Nov 06 '15 at 21:53
  • What do you mean by ignore? the ico change I'm talking about is this http://stackoverflow.com/questions/10927109/custom-icon-for-clickonce-application-in-add-or-remove-programs – Jack Nov 07 '15 at 02:16
1
object myValue = myKey.GetValue("UrlUpdateInfo");
if(myValue != null)
{
    string updateinfo = myValue.ToString();
    string updateLocation = ApplicationDeployment.CurrentDeployment.UpdateLocation.ToString();
    if (updateinfo==updateLocation)
    {
        myKey.SetValue("DisplayIcon", iconSourcePath);
        break;
    }
}
ezxizt
  • 36
  • 4