Custom folder icons with desktop.ini amp; instant refreshing(带有 desktop.ini amp; 的自定义文件夹图标瞬间提神)
问题描述
我的任务是创建一个簿记程序,该程序会跟踪读取文件和文件夹的时间的一些统计信息.与 Google Drive 和 TortoiseSVN 类似,文件夹和文件图标应反映某些更改.例如,带有未在某台计算机上查看过的文件的 USB 带有x",而查看过的文件带有o".
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'.
我可以使用 this Windows API 和图标(以及其他一些不错的选项)可以通过 desktop.ini 文件进行更改 [1,2,3,4].
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].
在手动处理 desktop.ini 文件的同时,我已经成功地更改了图标、描述和其他有趣的东西.问题是在 Windows 再次解析 desktop.ini 文件之前,新更改不会更新.这往往会在几秒钟到几分钟之间不一致地发生.F5 刷新不会强制重新解析,但会在发生重新解析时更新图像.
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.
如何强制 Windows 手动和(更重要的是)在 C++ 程序中重新解析 desktop.ini 文件?
是否有替代的 C++ Windows API 可以立即更改文件夹图标?
推荐答案
如果您编辑 desktop.ini,它资源管理器将不会自动刷新.使用 SHGetSetFolderCustomSettings 写入:
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);
这篇关于带有 desktop.ini & 的自定义文件夹图标瞬间提神的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 desktop.ini & 的自定义文件夹图标瞬间提神
基础教程推荐
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- CString 到 char* 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
