I am now programming a small tool and need to refresh the folder icon instantly.
As we know, in Windows, we could modify folder icons by the following steps manually:
I also know how to set the desktop.ini file to modify its icon. But it takes really a long time to refresh (about 30 seconds).
I wanna know if there is a common way to solve it instantly no matter using C/C++ or script. Or Windows never provides a way?
This small C program will do the job:
#include <windows.h>
#include <ShlObj.h>
const char folderpath[] = "C:\\Your-Folder";
int main() {
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, folderPath, NULL);
}
folderpath is the full path to the folder whose icon is to be updated
Following sequence of operations works fine here (Windows 10 64 bits):
Desktop.ini file
[.ShellClassInfo]
IconResource=C:\Windows\System32\SHELL32.dll,12
Check the SHChangeNotify function for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With