如何实现将本机系统中的某个文件夹中的文件刷新一遍,类似windows 里面的刷新文件和文件夹,(30分)

  • 主题发起人 主题发起人 laoyou
  • 开始时间 开始时间
请参考Delphi的例子,在Demo/Virtual ListView/中。
 
希望能找到用 windows api 函数实现某文件夹里的文件刷新的功能,[:)][:)][:)]
 
看看能不能用,我还没有用过;<br><br><br>SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST+SHCNF_FLUSH,nil,nil);//刷新文件关联图标<br>其中SHChangeNotify还有多个地方可以刷新,具体的看帮助!<br>SHChangeNotify(SHCNE_ALLEVENTS , SHCNF_FLUSH,nil,nil);//发生所有的事件,系统应该刷新响应的项目<br>function SHUpdateRecycleBinIcon():boolean;stdcall;external 'shell32.dll' name 'SHUpdateRecycleBinIcon';//刷新回收站图标<br>SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);//通知系统设置改变<br>var<br>buf:pchar;<br>...<br>getmem(buf,SizeOfBuf);//<br>strpcopy(buf,'注册表的主键,例如Software/Microsoft/windows/currentversion/Explorer/ToolBar');<br>SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,buf);<br>//通知系统刷新响应的键值,如果前面的没有起作用,那么可以采用这个方法。<br>systemparametersinfo(SPI_SETDESKWALLPAPER,0,pchar(path),0);<br>//上面的是通知系统更改了墙纸,其中path为墙纸的路径。<br>同样,SystemParametersInfo()还可以对系统进行很多方面的刷新,例如更改了桌面的大小等等,你可以看看帮助,我不可能在这儿把所有的都写出来。<br><br>要做到象Tweak UI那样Rebuild ICON,可以采用下面的方法:<br>:delphifan <br>这个问题确实很有意思,害得我找了很久,请看答案:<br><br>&nbsp; Reg := TRegistry.Create;<br>&nbsp; try<br>&nbsp; &nbsp; //设置图标<br>&nbsp; &nbsp; Reg.RootKey := HKEY_LOCAL_MACHINE;<br>&nbsp; &nbsp; if Reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/explorer/Shell Icons',True) then <br>&nbsp; &nbsp; &nbsp; Reg.WriteString('3','C:/WINDOWS/SYSTEM/shell32.dll,15');<br>&nbsp; &nbsp; //修改icon size<br>&nbsp; &nbsp; Reg.RootKey := HKEY_CURRENT_USER;<br>&nbsp; &nbsp; if Reg.OpenKey('/Control Panel/Desktop/WindowMetrics', True)<br>&nbsp; &nbsp; then Reg.WriteString('Shell Icon Size','31');<br>&nbsp; &nbsp; //通知windows<br>&nbsp; &nbsp; SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,0);<br>&nbsp; &nbsp; //当然别忘了改回来<br>&nbsp; &nbsp; Reg.WriteString('Shell Icon Size','32');<br>&nbsp; &nbsp; SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,0);<br>&nbsp; finally<br>&nbsp; &nbsp; Reg.CloseKey;<br>&nbsp; &nbsp; Reg.Free;<br>&nbsp; end;<br><br>关键是强迫windows重新刷新 icon cache,通过修改icon大小是一种可行的办法,<br>虽不排除有其他办法,但试验了几个没通过,大家不妨多发掘一下.
 
再给你一个<br><br><br>RedrawWindow(0,nil,0,RDW_ERASE or RDW_INVALIDATE or RDW_ALLCHILDREN);<br>        |   |        ---  ----<br>       handle RGN(可刷新局部屏幕) <br><br>procedure RefreshDesktop; <br>var c1 : THandle; <br>begin <br>c1:=windows.FindWindowEx(windows.FindWindowEx(windows.FindWindow('Progman','Program Manager'),0,'SHELLDLL_DefView',''),0,'SysListView32',''); <br>PostMessage(c1,WM_KEYDOWN,VK_F5,0); PostMessage(c1,WM_KEYUP,VK_F5,1 shl 31); <br>end; <br><br>*************<br>SendMessage(FindWindow('Progman', 'Program Manager'), WM_COMMAND, $A065, 0); <br>
 
多人接受答案了。
 
后退
顶部