views:

451

answers:

1

In my program I toggle the registry value of hidden files to tell explorer whether to hide or show them. However, since explorer doesn't refresh on it's own, I send the event

 SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);

to refresh everything. However, it doesn't seem to be refreshing anything unfortunately. I see the screen on the desktop flicker a bit, but in order to see the changes, I have to manually refresh the folder. SHChangeNotify doesn't seem to be working for me. Any help would be greatly appreciated.

A: 

Try SHGetSetSettings with your change to fShowAllObjects

A simple Get and Set with SHGetSetSettings won't work though.

It's smart enough to compare it's current settings to what your sending it and will only notify other windows of the change if the two are different.

To refresh the desktop use SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, null);

Sheng Jiang 蒋晟
Could I have a code snippet? I tried to use SHGetSetSettings and it didn't solve my problem.
Null
Sheng Jiang 蒋晟
var shellState = new SHELLSTATE(); shellState.fShowExtensions = 1; SHGetSetSettings(ref shellState, SSF.SSF_SHOWEXTENSIONS, true);^^^ That's what I'm doing in my code. Still doesn't help. :\
Null
mmm, try change HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced first, then broadcastWM_SETTINGCHANGE with "ShellState" and SMTO_ABORTIFHUNGm. If that does not work try SHChangeNotify with SHCNE_ASSOCCHANGED and SHCNF_IDLIST
Sheng Jiang 蒋晟