This actually can be done (i.e. you can make Windows 7 recognize the notification icon as being the same one even though ClickOnce has changed the path of your executible during an update). It's just very finicky and requires that every single one of the below criteria are met with exacting precision:
- Generate a GUID on your dev machine and set the guidItem member to it on every call of Shell_NotifyIcon. It must always be the same GUID, even between release versions of your app (kinda the point here).
- Set the NIF_GUID flag on every call to Shell_NotifyIcon.
- Digitally sign the assembly with an Authenticode certificate that will be trusted on the target machine (i.e., a real one).
If the settings are not being saved regardless of path -OR- Shell_NotifyIcon starts tossing false back at you, that means either:
- You're making at least one call to Shell_NotifyIcon somewhere in your code that is not setting the guidItem member of the struct appropriately or is not setting the NIF_GUID flag.
- You didn't really sign the executible binary. If you're using Visual Studio to do this, it's really bad about not telling you when signatures fail because of configuration issues. Check the properties of the file in Windows Explorer and ensure you can get to the tab that shows you the signing cert.
- Your certificate isn't trusted on the target machine.
If you mess up at some point and Shell_NotifyIcon starts returning false and just won't seem to stop, generate a new GUID to start the process over again.
Also Note: Check the OS version to make sure you're on Windows 7 or above when ever you try to do anything concerning a notify icon with a GUID. Windows Vista and below will freak out.
Example:
var os = Environment.OSVersion.Version;
if (os.Major > 6 || (os.Major == 6 && os.Minor >= 6))
{
lpData.guidItem = Guid.Parse("Your Own Guid Here");
lpData.uFlags |= FlagEnum.NIF_GUID;
}