当desktop.ini更改时,如何立即重新加载文件夹图标

发布于 2024-11-17 05:35:50 字数 115 浏览 2 评论 0原文

我一直在尝试使用更改文件夹上的desktop.ini 以编程方式更改文件夹图标。我能够设置图标,但无法通过更改“IconIndex”立即更改它。几秒钟后,图标也发生了变化。

有谁知道如何立即更改图标吗?

I've been trying to change folder icon programmatically using changing desktop.ini on the folder. I was able to set an icon, but couldn't change it immediately through changing "IconIndex". The icon was also changed in a few seconds later.

Is there anybody know how to change the icon immediately?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

再可℃爱ぅ一点好了 2024-11-24 05:35:51

例子:

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

Example:

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);
静若繁花 2024-11-24 05:35:51

以下过程对我来说效果很好(在 Windows 7 上):

  1. 更改desktop.ini 文件
  2. Issue SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,"path_to/desktop.ini",0);
  3. 文件夹ico将被刷新

记住包含Shlobj.h

The following procedure works well for me (on Windows 7):

  1. Change desktop.ini file
  2. Issue SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,"path_to/desktop.ini",0);
  3. Folder ico will be refreshed

Remember to include Shlobj.h

幸福不弃 2024-11-24 05:35:50

我之前已经通过评论回复我的问题来回答过。为了方便大家,我再写一个答案。

如果要使用 Desktop.ini 对任何文件夹的外观进行任何更改,请使用一些 win32 shell 函数。您不应尝试直接编辑 Desktop.ini。它不会对任何文件夹的外观进行任何更改。

您可以通过以下链接获取有关 win32 shell 函数的更多信息。

http://msdn.microsoft。 com/en-us/library/windows/desktop/bb776426(v=vs.85).aspx

I already answered by commenting a reply at my question before. For more convenience, I will write an answer again.

If you want to make any change at an appearance of any folder using Desktop.ini, use some of win32 shell functions. You shouldn't try to edit a Desktop.ini directly. It doesn't get to make any change at an appearance of any folder.

You could get more information of win32 shell functions through the following link.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb776426(v=vs.85).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文