简体   繁体   中英

Custom folder icons with desktop.ini & instant refreshing

I am tasked with creating a book-keeping program that tracks some statistics of when files and folders are read. Similar to Google Drive and TortoiseSVN, the folder and file icons should reflect certain changes. For instance, a USB with files that haven't been viewed on a certain computer have an 'x', whereas viewed files get a 'o'.

I can track file usage with this Windows API, and icons (as well as some other nice options) can be changed by the desktop.ini files [ 1 , 2 , 3 , 4 ].

While manually messing around with desktop.ini files, I've successfully changed icons, descriptions, and other fun stuff. The problem is that the new changes don't update until Windows parses the desktop.ini file again. This tends to happen inconsistently between a few seconds to several minutes. F5 refreshes do not force a reparse, but will update the image if a reparse has occurred.

How do I force Windows to reparse desktop.ini files both manually and (more importantly) in a C++ program?

Is there an alternative C++ Windows API that can change folder icons immidiately?

If you edit desktop.ini, it Explorer won't refresh automatically. Use SHGetSetFolderCustomSettings to write to it:

SHFOLDERCUSTOMSETTINGS fcs = {0};
fcs.dwSize = sizeof(SHFOLDERCUSTOMSETTINGS);
fcs.dwMask = FCSM_ICONFILE;
fcs.pszIconFile = iconPath;
fcs.cchIconFile = 0;
fcs.iIconIndex = iconIndex;
SHGetSetFolderCustomSettings(&fcs, folderPath, FCS_FORCEWRITE);

If you wish to have different folder icons to indicate different states distinctively (similar to SVN) then you need icon overlays. Changing folder icons is not the suitable solution. The changes in folder icons will reflect instantaneously If you need further details, Please let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM