WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Desktop

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Refresh Desktop

Keywords:   Refresh Desktop

Question:

I'm running NT40 with Option Pack 1 (Active Desktop)

Has anyone figured out how to "Refresh" the desktop from WinBatch? (This is the right click on the desktop, selecting option "Refresh" from the context menu.)

Answer:

SHChangeNotify

	SHCNE_ASSOCCHANGED=134217728
	SHCNF_FLUSH=4096
	dllfile=strcat(dirwindows(1),"shell32.dll")
	DllCall(dllfile, void:"SHChangeNotify", long:SHCNE_ASSOCCHANGED, long:SHCNF_FLUSH,lpnull, lpnull)	

OR

If the previous code doesn't work try something like..

	mydir = ShortCutDir("Desktop")
	bb=BinaryAlloc(2048)
	BinaryPokeStr(bb,0,mydir)
	dllfile=strcat(dirwindows(1),"shell32.dll")
	DllCall(dllfile, void:"SHChangeNotify", long:4096, long:1, lpbinary:bb, lpbinary:bb)
	BinaryFree(bb)


WallPaper Trick

Another possible technique would be to use the WallPaper function specifying your current desktop wall paper. The WallPaper function calls an underlying shell COM interface method to do the equivalent of f5 on the desktop. I haven't tried this approach so I can't guarantee that it will work but I can't think of a reason why it wouldn't either.
WallPaper(SysParamInfo(115,0,0),0)


Explorer refresh of "My Documents"

	mydir = ShortCutDir("Personal") 
	bb=BinaryAlloc(2048)
	BinaryPokeStr(bb,0,mydir)
	dllfile=strcat(dirwindows(1),"shell32.dll")

	DllCall(dllfile, void:"SHChangeNotify", long:4096, long:1, lpbinary:bb, lpbinary:bb)

	BinaryFree(bb)

Article ID:   W13177
Filename:   Refresh Desktop.txt
File Created: 2014:02:13:10:23:56
Last Updated: 2014:02:13:10:23:56