Modifying the Windows Explorer Toolbar with WinApi / c++ - c++

My task is to program change sorting parameter of files and folders in my operating system.
In the article on the MSDN:
under
Modifying the Windows Explorer Toolbar
indicated
In addition to modifying the Windows Explorer menu bar, you can also add buttons to the toolbar. And an example code.
But example of this modifying the Windows Explorer menu bar is not there, the only thing is there it's button adding example.
An alternative article has an example of opening it, so my question is: is it even possible, and if it is, how to do it?

The folder sort settings are saved to:
HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\
HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU
The entries look like:
You would need to loop through all of these registry entries and change the 'Sort' key. This would only affect folders which have already been accessed.
If you want to see how these lists are parsed, run ShellBagsView while running ProcMon and log all the interactions with the registry.
To do it, not programatically you can follow these instructions:
https://superuser.com/a/1481763/1043059

Related

Disabling menu compression in MFC

My English is not perfect. I am using Visual C++ 2019 and MFC. At my MDI-program, the menus are compressed: I do not see all the items, there is a double-arrow-like something on bottom of the menu, I always must click to them. I can not disable this. At Resource View, I can not open the whole menu's Properties Page, only for the File, etc. menu's Properties Page. I did not find the disabling on the Properties Page. In the code, in MainFrm.cpp, CBRS_SIZE_DYNAMIC and CBRS_FLYBY occur 2+2 times. I tried to put to comment them, but this did not solve the problem. How can I disable the compression? Thank you.
I can not open Properties Page of the whole menu. Maybe it has not Properties Page, or the cause is the lack of High DPI support in Visual Studio. For example, I can not edit icons: the icon editor is unusable. At the generated program, it seems the High DPI support of toolbar is depend on the style. At WinAPI programs, there are 3 pixel stairs: emulates 1/3 resolution. There is 3*96 dpi = 288 dpi at me, 0,16 mm * 3 = 0,48 mm.
Use CMFCMenuBar::SetShowAllCommands
Remarks
If a menu does not display all the menu commands, it hides the commands that are rarely used.
Whether the application should display all menu items or just the most recently used ones (and the user will have to expand the rest) is an option that can be set by the user: Toolbar Options->Add or Remove Buttons->Customize->Options->Personalized Menus and Toolbars->Menus show recently used commands first. This option is saved in the registry under HKEY_CURRENT_USER\SOFTWARE\CompanyName\ApplicationName\Workspace\MFCToolBarParameters\RecentlyUsedMenus, so the application "remembers" it.
Programmatically it can be changed using the CMFCMenuBar::SetRecentlyUsedMenus() function - it's a static function.
It would be best to let the user decide how the application should work, so I would recommend that you do... nothing about it. Or, you could set it to FALSE, but only for the very first time the application is run. Add a new boolean value in the registry, under ...ApplicationName\Workspace or ...ApplicationName\Settings, with a value always set to TRUE. The best place to do this is the SaveCustomState() member function of your application class. In the LoadCustomState() read that value (default FALSE), and if it is TRUE call CMFCMenuBar::SetRecentlyUsedMenus(FALSE);.

Windows 10 - Taskbar - Add item to context menu for each program

I need a context menu entry for each program in the taskbar. Want to add an entry which immediately terminates (UNIX/Linux-like signal SIGKILL) the process. There a lot of questions on this site, how it's done for the explorer or desktop. But is it also possible to add such an option to the context menu of the taskbar?
To clarify the question, according to my comments:
The current problem:
I have a program (not Firefox) which randomly crashes. The program is in fullscreen mode. But if I want to close the window of the program with Exit window, it takes a long time that Windows kill the program. When I try to open the Task Manager the program immediately grabs the user input and I have no chance to interact with the Task Manager. So my solution was to add a context menu item in the taskbar to quit the task of the program. According to a user comment, I test the option "Always on top" in the Task Manager. Didn't know that. But I haven't tried it yet. I'm also interested for further projects, if there is a function in WINAPI or Windows Registry to add an item.
To avoid down-votes:
I'm not interested to hack Windows or the application. Solutions with code injection are taboo for me. Want a clean solution, if even possible. I want improve my Windows version. Adding also some additional information (process information) in the context menu.
Have currently found this (Registering shell extension handlers).
Has anybody used this before? I think it's sound promising.
There is no API to extend this menu like that. Applications can customize the top of the menu with ICustomDestinationList but there is no way to add entries for all applications.
For a personal use project, you could inject a .dll in the taskbar instance of Explorer.exe and add your item after figuring out the address of the function where the menu is created. This address can of course change after you upgrade Windows so it is not a very generic solution. Using the public symbols might help but you still have to expect it to break from time to time when Microsoft changes part of their taskbar code.
You don't need to change code in explorer.exe, because you can close a program by doing the keyboard shortcut: Alt + F4.

Shell extension windows : best communication between ContextMenu and IconOverlay?

Hello windows experts,
I am searching for a simple way to activate an overlay on files using the context menu. Tortoise SVN gives an example of what can be done. But is very complex compared to my simple need.
For now I am looking at approaching it this way using C++:
http://www.codeproject.com/Articles/545781/NET-Shell-Extensions-Shell-Icon-Overlay-Handlers
http://www.codeproject.com/Articles/10104/Add-a-context-menu-to-the-Windows-Explorer
The issue is to create the link between both of them. The following link suggests to make a map but I am quite puzzle about how:
What the best Language to use when creating Windows Shell Context Menu?
You can use the Registry, for example store an Enabled value in the HKEY_CURRENT_USER\YourCompany\YourApp key. When the user executes your menu item to turn on/off the functionality, write the appropriate value into Enabled and then call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil). That will cause the shell to re-read icons, including icons from your overlay extension. Inside the IsMemberOf method of your IconOverlay handler, check your Enabled value and return S_FALSE if the functionality has been turned off.

Application icon is not getting displayed in control panel add/remove programs

I have a c++ application. The app icon shows fine on the start menu, task bar etc., but not in Add / Remove Programs in the control panel. What do I need to do to fix this?
Control panel add/remove program reads all the programs list from registry.
For XP it's HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
you can take backup of your registry, and remove your program name from this registry.

can I set the AppUserModelID of an arbitrary process launched through a jumplist?

I have a simple console application written in C++ that acts as a stub for launching another application through it's jumplist. Purpose is to add jumplist abilities to applications that do not support this. Call it stub.exe. When running stub.exe it creates a custom jumplist using these steps (taken right form the MS samples):
create an ICustomDestinationList
ICustomDestinationList::BeginList()
create an IObjectCollection
for_each item_to_add
create an IShellLink, set its path/arguments/title/icon
add IShellLink to the IObjectCollection
get the IObjectArray interface from the IObjectCollection
call ICustomDestinationList::AddUserTasks( IObjectArray interface )
ICustomDestinationList::CommitList()
When pinning stub.exe to the taskbar and right-clicking it, the jumpilst appears and it contains all IShellLinks added. When clicking an item, it will launch the corresponding process.
Now I'd like a process launched through this jumplist have it's window(s) grouped under stub.exe's taskbar icon, instead of having it's own group. They key to get this working seems to be the AppUsermodelID. This is what I tried so far:
just for testing, create a couple of shortcuts and set the id through IPropertyStore->SetValue( PKEY_AppUserModel_ID, "id" ). Indeed, when launching these shortcuts, they will all group under the same taskbar icon.
since the shortcuts do what I want, I tried adding shortcuts to stub.exe's jumplist: no effect. The shortcuts don't even show up in the jumplist (maybe one cannot have a shortcut to a shortcut?), yet all methods return S_OK
setting the PKEY_AppUserModel_ID on each of the IShellLinks that get added to the jumplist: no effect
calling ICustomDestinationList->SetAppID(): no effect
instead of using SubTasks, tried with SHAddToRecentDocs: no effect. The recent doc list does not show up. But now things get messy. After setting the AppUserModelID on the shortcut that is responsible for the pinned taskbar item (the one in %APPDATA%/Roaming/Microsoft/Internet Explorer/Quick Launch/User Pinned/TaskBar), the jumplist changed: it does not show the 'Tasks' item anymore, but does show 'Recent' and the items I added using SHAddToRecentDocs. Now when clicking them I get a dialog box with a title that starts with 'd:\desktop' followed by Chinese characters. Hovering the items in the jumplist also shows Chinese characters instead of the descirption I set.
Questions:
What's with the Chinese characters in the jumplist?
How come setting the app id on the taskbar shortcut toggles between 'Tasks' and 'Recent' sections, why are they not both there?
What would be the way, if even possible, to achive what I actually want: a custom jump list of which the items launched will group under it's taskbar icon? (note that the processes I plan to laucnh their do not have their app id set currently)
not much reactions here ;]
In the meantime I managed to solve the main problem myself; it's not quite a straightforward solution but it fullfills the requirements: a program runs in the backround and installs a CBT hook. Each time an application creates a window (HookProc code = HCBT_CREATEWND), the hook checks the application's path against a map containing paths and desired application ids. If a match is found, the application id of the HWND is set. Since this occurs before the window is actually shown and is combined with the custom task list, from a user's point of view the application behaves just like one that does support a recent/pinned document list.