SHGetPropertyStoreForWindow - How to set properties on existing System.AppUserModel.ID - winapi

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. :(

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)

Related

Find the relation between ".automaticDestinations-ms" and it's file?

Does anyone know (Because on microsoft forums nobody answered me), how can I find what app has which automaticDestinations-ms file in %appdata%\microsoft\windows\recent\automaticdestinations ?
That's the folder where Windows 7 stores its jump lists, and I want to know how to automatically/programmatic find the relation between each file and an application.
At least, even manual I didn't found any pattern, just to look after file extensions in the files, because some programs open files with the same extension (like images), so this method it's not OK for all programs.
Do you have any other idea? Maybe knowing the format of those files?
Thanks.
the GUIDs appear to persist.
I was trying to edit my control panel jumplist - I found where the "Realtek HD audio manager" control-panel-applet-title-string is (using resource hacker on "C:\Windows\System32\RTSnMg64.cpl"), and restored it's original title ("Dell Audio" - 'cause I'm OCD:) but the original pinned Realtek entry is stuck.
A quick filesearch for pinned took me to
C:\Users\Jonny\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned
but I really needed to be # C:\Users\Jonny\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations
If you use something like Nirsoft's Jumplist View you can see the entries etc. Sort by "application ID" column to see jumplists by application. You can even change the monitored folder (advanced options).
I'm going to have to delete and recreate my control panel jumplist (7e4dca80246863e3.automaticDestinations-ms).
TIP: If you're not sure which is which, try pinning a new jumplist-entry to an application. This will appear at the top (if sorted by "record time")
The best way to find out is to sort the files by date modified, then interact with your machine, eg open a file with Powerpoint, look and see what file moved to the top. That is probably the file for Powerpoint, which you can confirm by opening it and looking in it.
Then you could build a table of magic guids, and search for those in the registry to see if there is an obvious key connecting the guid to an application id.
Here is a list of 620 applications here with the corresponding App ID byEricZimmerman
https://github.com/EricZimmerman/JumpList/blob/master/JumpList/Resources/AppIDs.txt
eg 0a1d19afe5a80f80|FileZilla 2.2.32
last update 12 days ago

IFileSaveDialog - choosing folders in Windows 7

In Vista, I have been using an IFileSaveDialog to let users pick a "save-as" folder. Users export a folder of images, say, and need to choose a new or existing target folder.
Briefly, the code goes like this:
IFileSaveDialog* dialog; // created
dialog->SetOptions(FOS_PICKFOLDERS);
dialog->Show(NULL);
dialog->GetResult(&shellItem)
In Windows 7, the FOS_PICKFOLDERS option appears to have been disallowed (and is marked as such in the API). The return value on the SetOptions call is E_INVALIDARG. If I use a IFileOpenDialog, I'm allowed to set the folders option, but the user is prompted with an error when choosing a nonexistent folder (despite my setting flags suggesting not to do this).
Is there an alternate way to get the new IFileDialog to act as a "save folder" dialog?
[To head off some comments, the SHBrowseForFolder API still exists, but is still not an acceptable solution for our UI deciders.]
The reason for this can be found in the documentation:
FOS_PICKFOLDERS: Present the Open dialog offering a choice of folders rather than files.
Using FOS_PICKFOLDERS for "save" was never supposed to be supported - but Vista didn't enforce it. Use IFileOpenDialog instead and you're good to go.
You are picking an existing folder (not specifying a folder to create), so open was always the correct choice.
I haven't played around with the Windows 7 dialogs yet, but downloaded the Windows® API Code Pack just this morning as I am implementing the Thumbnail Toolbar and Icon Overlay in the application I am working on. It'll probably point you in the right direction.

Replacing the Start Menu

I want to make my own Start Menu replacement and I am trying to figure out what approach to use. There are a number of ways the Start Menu is activated: click on it, hit windows key, hit Ctrl+Esc keys or tab until it gets focus and hit the space or enter key.
I know enough about win32 to do each one of these separately and I could figure it out with Spy++. I'd really like to know if there is an easier way through and I can't find any helpful articles.
I'd like to do this for XP and Vista/Windows 7.
I guess that you would have to inject yourself into the explorer.exe process (There can be more than one, but you want the one that has the "Shell_TrayWnd" window) and subclass the taskbar or one of its children to catch/eat the message that brings up the startmenu and instead, show your own window.
Take a look at http://bitbucket.org/wez/evildesk/src/755606d7935d/gdi.cpp , I think you could start your project by seing what they've done.
You can use WindowBlinds and design your own Start Menu as well.

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Windows internet shortcuts: starting with IE maximized?

I have an internet shortcut on my desktop, with the contents looking like this:
[InternetShortcut]
URL=http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=6&ar=IStart
Modified=D03458CE7738C801A2
I was wondering if there are any tweaks I can do to guarantee that the browser starts maximized after someone loads the link.
Thanks!
In short:You can't guarantee that the browser starts maximized from one special internet link. Either all or none internet links start maximized.
But: Someone had a similar problem than this.
Check this, if it helps you.
Edit: owhowho I've found something really dirty, I think you shouldn't use this, but... here it is. Replace your second line with the following:
URL=javascript:window.moveTo(0,0);window.resizeTo(screen.width,screen.height);window.location.href="http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=6&ar=IStart";
It doesn't make the window really maximized, but makes the browserwindow the maximum height and width.
Rather than using a internet shortcut (.url), create a shortcut (.lnk) to internet explorer. (iexplore.exe) You can set the initial windows state in lnk file. (Right-click the icon and see properties.)
You can give an URL as an argument. The target would be something like
"%programfiles%\Internet Explorer\iexplore.exe" http://reddit.com
This is okay when you are using this only in your computer. This is not a general solution. If you want to do this programatically, there are some windows API's related to creating a shortcut. You will also have to get an path of internet explorer from the registry, as it can vary. Some users might not have IE.
I think IE remembers how it was opened last time and then uses those settings.
You might find this info from Registry and use it, but I doubpt that it was implemented to get the values from startup arguments
You're jumping quite quickly to conclusions here. I don't think you can even guarantee that Internet Explorer will start at all; you will get whatever the user set as his default browser.
i think that it is a guarantee that the internet explorer will start unless the system is down. even if one gets the default window, from there it is very easy for you to set the browser to what you want.

Resources