Search code examples
windowsrefreshexplorertaskbar

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


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.


Solution

  • 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"));