XP中更改文件关联后如何刷新图标? [英] how to refresh icon after change file association in XP?
问题描述
大家好
我试图在XP中更改.htm文件的文件关联,这是我的操作方法:
1.更改关联的注册表项值.
2.调用SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,0,0)刷新图标;
完成这些操作后,我双击.htm文件,然后由预期的浏览器将其打开.但是桌面上的图标不会更改为新图标(例如,从IE到Chrome).但是,如果重新启动explorer.exe,图标将更改为正确的图标.
谁能告诉我更改文件关联后如何刷新桌面上的图标?
感谢您的任何答复.
Hi all
I tried to change file association of .htm file in XP, and here is how I did it:
1. Change the associated registry key values.
2. Call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0) to refresh the icon;
After doing these, I double clicking the .htm file, and it is opened by the browser I expected. But the icon on the desktop is not changed into the new one(e.g. from IE to Chrome). However, if I restart explorer.exe, the icon changed to the correct one.
Can anyone please tell me how to refresh the icon on desktop after changing the file association ?
Any replies from you will be appreciated, thanks.
推荐答案
您可以使用WINAPI函数SendMessageTimeout,该函数接收消息与当前线程属于同一队列,即窗口该过程将直接调用-超时值将被忽略.以下代码将帮助您
You can use SendMessageTimeout WINAPI function, which receives the message belongs to the same queue as the current thread, the window procedure is called directly—the time-out value is ignored. The below code will help
DWORD result2 = 0;
LRESULT result = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,(LPARAM)_T("Environment"), SMTO_ABORTIFHUNG, 5000, &result2);
我从网上找到了两种解决方案:
1.在注册表中更改图标大小,然后将其更改回,并使用
发送消息 SendMessage(HWND_BROADCAST,WM_WININICHANGE,0,0);
上面解决方案的副作用是,即使未启用自动排列,它也会重新排列桌面上的图标布局.
2.SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,0,0);
这样就可以完成工作,并且完全没有副作用.
There are two solutions I found from web:
1.change the icon size in the registry then change it back, and sendmessage with
SendMessage(HWND_BROADCAST,WM_WININICHANGE,0,0);
The side effect of solution above is that it will re-arrange the icon layout on the desktop even the auto-arrange is not enabled.
2.SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
This can do the job and have no side effect at all.
这篇关于XP中更改文件关联后如何刷新图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!