How can I refresh the Taskbar programatically in Windows 10 and higher? - windows

Right off the bat, please don't judge too harshly, I'm still relatively new to this forum and not too practiced at formulating my question yet :)
Background:
Because I have to install Windows and do it's configuration on new computers very often, I found some settings are always the same but anyway important (like showing filetyype endings, disable cortana and news & interests, pin Word/Excel to taskbar, etc.)
Problem:
My problem is about the task-view button - I set it hidden in registry (but let the chance to reactivate it anytime). Sure - you can make a change to the taskbar settings manually, but per program this won't work. Because of such changes won't adapt until reboot or restart of "explorer.exe" under normal circumstances:
How can I disable the taskview button (or refresh the taskbar in general) programmatically without killing any process?
And no - other similar questions don't help, since they're related to either the systray or old OS' it's solution are not longer working.
My Environment:
Windows 10 32/64-Bit 21H1
I'm happy with pretty much any solution, no matter the program language.
Thanks in advance for your help.

DWORD data = 0;
SHSetValueA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", "ShowTaskViewButton", REG_DWORD, &data, 4);
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) TEXT("TraySettings"));

Related

Get flashing window in delphi (window that needs focus and windows won't set it to front)

I was searching on internet how to enable "auto-switch" or "auto-raise" window that has flashing button on taskbar in Windows 7,
and all I can find is how to disable that! I need just opposit, to enable that so i looked at that answers and found registry key
ForegroundLockTimeout. It is set to 200000ms by default i think, so i set it to 1ms, but that doesn't affect anything after Windows XP I guess..
I found that it used to be possible to enable auto switching in Tweak UI from Microsoft, but that doesn't seems to work on Win 7 either.
I tried to program that in Delphi and I can set window on top with SetForegroundWindow, but i can't detect which windows need attention - are flashing.
It is even possible to detect foreground window with GetForegroundWindow, but not window that is flashing so i could set it on top.
So my question is, is it possible in delphi to get hwnd of that window that needs focus in background?

How to force update of ShellIconOverlays on files in Windows File Explorer [duplicate]

I have a Windows shell extension that uses IShellIconOverlayIdentifier interface to display overlay icons on files and folders. My extension is a little like TortoiseCVS or TortoiseSVN.
Sometimes I need to make Windows Explorer redraw all it's icons. To do this, I call SHChangeNotify like this:
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL)
This refreshes the desktop and right hand pane of any open explorer windows. It doesn't refresh the folder tree on the left hand side of any Explorer windows.
So I tried sending WM_SETTINGCHANGE like this:
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
on Vista this refreshes the folder tree, but not the right hand pane.
The combination of SHChangeNotify() followed by WM_SETTINGCHANGE seems to work quite well on Vista. But I still can't refresh the folder tree on XP if it is displayed.
Does anyone have any ideas how to do this better?
Is there a better solution for XP?
Sending SHCNE_ASSOCCHANGED is a bit like clubbing Explorer over the head. It causes the whole desktop to refresh quite violently and casues any open Explorer windows to loose there scroll position. Is there anything that's a bit less violent?
Does anyone have any ideas how to do
this better?
Personally I don't know. You mention the Tortoise programs which do a similar thing, so an excellent starting point would be to have a look at what they do in their source :)
These look to be the relevant source files that handle this problem:
TortoiseCVS - ShellUtils.cpp
TortoiseSVN - ShellUpdater.cpp (username: "guest", password: "")
I note in the RebuildIcons method in each of those will:
set the shell icon size or colour depth to a temporary value
updates all the windows by broadcasting the setting change
resets the shell icon size or colour depth to the original value
updates all the windows a second time with a broadcast of the setting change
Perhaps this is part of the trick to get things working in XP.
Use spy++ to see what WM_COMMMAND message gets sent when you press F5 in windows explorer or find what menu message is used for view/refresh
Then use FindWindow to get the explorer window you want and send the WM_COMMAND recorded earlier etc message to it.
This is a fun way to control all sorts of Windows programs.
You can also send a WM_KEYDOWN message with the F5 keycode to all open explorer windows. This is a bit of a hack though.

Quick Launch toolbar keeps randomly disappearing (windows 7)

I am really used to quick launch toolbar from windows XP. When I moved to Windows 7, I replicated this functionality using some of the guides, such as here or here.
But every now and then it simply disappears and I have to go through the adding process again. It happens approx. once a month. I haven't managed to track anything, what it would be related to (crashes, headaches, windows updates, new program installations...). It seems to me to be completely random.
There is quite a few posts about this issue in the internet, but either the problem is "it always disappears" (like here or here), or the answer is "add it back like this" (here), or the answer didn't help me (like here or here).
Any idea appreciated.
Disable the Language Bar, then recreate the Quick Launch Bar. That should do it. The Language Bar interferes with it.
Try Disabling Windows Maintenance Mode.

Ghosts windows when color scheme is NOT Aero on Vista

We have a service that launches an application that will interact with the logged on user. The application we launch is always run as a specific user for which we have the credentials. We do what is necessary (get active session ID, logonUser, adjust token) and launch the application with CreateProcessAsUser in the winsta0\Default desktop.
Everything is working fine if the color scheme of the Vista PC is Aero - but under the basic and classic color schemes, the application is still launched but none of the windows are painted. There is a new task on the taskbar. If you minimize a window which was in the background and in full screen, then you can see the contour of our ghost app - you can move it around, it will respond to keyboard/mouse input just fine. It's just invisible, not painted.
Does anyone has any idea of what could be happening? Why with the Aero color scheme it's fine but not in the others?
Thanks for any help,
Frank
It sounds pretty weird - you may have hit on an actual bug in Vista since it seems unlikely many other people have tried what you are doing.
First of all I'd make sure the problem doesn't exhibit this behaviour when run by the logged in user directly, just to pin it down to whether it's a Aero/Classic issue or a winstation issue.
Secondly I'd attach to the process with a debugger and make sure the message loop is getting various significant messages, particularly WM_PAINT :)
But this is obscure enough that your only option may be to open a paid support issue with Microsoft.
There may also be a problem if you have user-drawn controls on your form (or your form itself is user-drawn). If you only paint the form if Application.RenderWithVisualStyles is true, you may see this behaviour. So make sure you also render stuff without these styles. More information how your form looks/behaves/etc would be appreciated.

How can I programmatically refresh Windows Explorer?

I have a Windows shell extension that uses IShellIconOverlayIdentifier interface to display overlay icons on files and folders. My extension is a little like TortoiseCVS or TortoiseSVN.
Sometimes I need to make Windows Explorer redraw all it's icons. To do this, I call SHChangeNotify like this:
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL)
This refreshes the desktop and right hand pane of any open explorer windows. It doesn't refresh the folder tree on the left hand side of any Explorer windows.
So I tried sending WM_SETTINGCHANGE like this:
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
on Vista this refreshes the folder tree, but not the right hand pane.
The combination of SHChangeNotify() followed by WM_SETTINGCHANGE seems to work quite well on Vista. But I still can't refresh the folder tree on XP if it is displayed.
Does anyone have any ideas how to do this better?
Is there a better solution for XP?
Sending SHCNE_ASSOCCHANGED is a bit like clubbing Explorer over the head. It causes the whole desktop to refresh quite violently and casues any open Explorer windows to loose there scroll position. Is there anything that's a bit less violent?
Does anyone have any ideas how to do
this better?
Personally I don't know. You mention the Tortoise programs which do a similar thing, so an excellent starting point would be to have a look at what they do in their source :)
These look to be the relevant source files that handle this problem:
TortoiseCVS - ShellUtils.cpp
TortoiseSVN - ShellUpdater.cpp (username: "guest", password: "")
I note in the RebuildIcons method in each of those will:
set the shell icon size or colour depth to a temporary value
updates all the windows by broadcasting the setting change
resets the shell icon size or colour depth to the original value
updates all the windows a second time with a broadcast of the setting change
Perhaps this is part of the trick to get things working in XP.
Use spy++ to see what WM_COMMMAND message gets sent when you press F5 in windows explorer or find what menu message is used for view/refresh
Then use FindWindow to get the explorer window you want and send the WM_COMMAND recorded earlier etc message to it.
This is a fun way to control all sorts of Windows programs.
You can also send a WM_KEYDOWN message with the F5 keycode to all open explorer windows. This is a bit of a hack though.

Resources