4

So I split my window from the main tab group via IPropertyStore via SHGetPropertyStoreForWindow like so:

IPropertyStore_SetValue(pps, PKEY_AppUserModel_ID.address(), 'Contoso.Scratch');
pps->Commit();

Then the user later decides he wants to rename it so with my feature he does:

IPropertyStore_SetValue(pps, PKEY_AppUserModel_RelaunchCommand, customLaunchPath);
IPropertyStore_SetValue(pps, PKEY_AppUserModel_RelaunchDisplayNameResource, 'my first name');
pps->Commit();

This works successfully for the first time. But if he wants to change just the RelaunchCommand and RelaunchDisplayNameResource again it won't work unless I change the ID as well.

I gave RelaunchCommand and RelaunchDisplayNameResource as exmple here, in my real case scenario the user ALSO wants to change the icon but the same issue, it works a first time per ID. Anyway to run multiple times without having to change ID every time?

Thanks

PS: The other big reason for this solution, is that one of my windows already has a System.AppUserModel.ID and is already pinned. I want to just change the icon/relaunchCommand/etc, if i change the System.AppUserModel.ID then it will effectively unpin it. :(

Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • Update! I was doing more research with this and I found that shortcut files are being created for this at `C:\Users\Noitidart\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\ImplicitAppShortcuts\********` where `******` is some random string like in one of my cases `bf87c237f79d59f1` and inside is a `.lnk` file with the `RelaunchDisplaynameResource` I set. So maybe I just have to delete that! I don't know but real interesting find! – Noitidart Jan 30 '15 at 07:43
  • 1
    I'd try updating the link's properties (icon, target, etc.) to reflect the change you're making. If this doesn't have an immediate effect, try logging out and in - if the change is then visible, it suggests you're on the right track. (Keep in mind that you're messing with implementation details, so even if you get it to work it could stop working at any point in the future, without notice.) – Harry Johnston Jan 30 '15 at 10:09
  • Thanks Harry, editing the files within are taking effect immediately, which is cool. But the bigger issue/question is how come subsequent calls with IPropertyStore on the `System.AppUserModel.ID` are not updating it? The docs say it should update it no? I even added in the commit but it the IPropertyStore (the documented way) is not working. :( – Noitidart Jan 30 '15 at 16:42
  • You're supposed to set all of those properties *before* the user pins your application, and they're not expected to change. Having the system look for and update existing shortcuts would presumably have been thought an unnecessary complication (if anyone thought of it at all). What you're trying to do does make sense in context, but it's the sort of scenario that's unlikely to occur to anyone in advance. – Harry Johnston Jan 30 '15 at 23:20
  • Thanks @HarryJohnston very much for your replies I'll keep my eyes peeled and if I come up with a solution to this I'll post. – Noitidart Jan 30 '15 at 23:34
  • Hey @HarryJohnston I kind of did a silly trick. To change the propertie son existing usermodelid, i would set the properties, then set the AppUserModel.ID to "DUMMY" then back to what its supposed to be. This is in case user unpins/repins but in order to get it show right in taskbar, the shortcut file had to have its properties updated. – Noitidart Jun 07 '15 at 02:50
  • 1
    @Noitidart This thread/question has been amazingly helpful, thanks for posting the updates! I'm using the WindowsAPICodePack library for working with this stuff and I'm not able to set the updated properties on a lnk file. Do you have any tips or advice for updating the lnk files to match the new & desired settings? I can't get the shortcut files inside ImplicitAppShortcuts to ever update. – Dave Jun 09 '17 at 18:47
  • Thank you @Dave for your comments! I really appreciate it! For the shortcut files, if I remember right, I would use `IShellLink`-`IPersistFile` to read the properties of the shortcut (lnk file), then delete it, then re-create the shortcut with the same properties/location. Updating them in place had no effect even though the api calls would not return error codes - if I recall correctly. – Noitidart Jun 09 '17 at 22:19

1 Answers1

3

The solution to this topic is the workaround I am using:

Detecting Application Pin State

Before setting property I test if it's pinned by looking in folders of:

  • %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\ImplicitAppShortcuts
  • %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

And I do a IPropertyStore::getValue on all the shortcuts, if it matches my AppUserModelID, then I change the icon, label, etc on that, which right away updates it in the taskbar.

This works but I'll leave this solution unaccepted as it's not documented so probably not the right way to go about it.

If the AppUserModel.ID is not found among the shortcuts, the i just to IPropertyStore::setValue on the windows of my application (I have to do on each window, i cant find a way to do it across the whole application)

Community
  • 1
  • 1
Noitidart
  • 35,443
  • 37
  • 154
  • 323