How can I programmatically refresh Windows Explorer?

霸气de小男生 提交于 2019-11-27 11:42:44

Does anyone have any ideas how to do this better?

Personally I don't know. You mention the Tortoise programs which do a similar thing, so an excellent starting point would be to have a look at what they do in their source :)

These look to be the relevant source files that handle this problem:

I note in the RebuildIcons method in each of those will:

  1. set the shell icon size or colour depth to a temporary value
  2. updates all the windows by broadcasting the setting change
  3. resets the shell icon size or colour depth to the original value
  4. updates all the windows a second time with a broadcast of the setting change

Perhaps this is part of the trick to get things working in XP.

Use spy++ to see what WM_COMMMAND message gets sent when you press F5 in windows explorer or find what menu message is used for view/refresh

Then use FindWindow to get the explorer window you want and send the WM_COMMAND recorded earlier etc message to it.

This is a fun way to control all sorts of Windows programs.

You can also send a WM_KEYDOWN message with the F5 keycode to all open explorer windows. This is a bit of a hack though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!