> Folder Options... >> View tab)." />
开发者

API to toggle "Show hidden files, folders and drives"

开发者 https://www.devze.com 2022-12-23 22:35 出处:网络
Is there a function in Windows API to toggle the \"Show hidden files, folders and drives\" option in Windows Explorer (Tools >> Folder Options... >> View tab).

Is there a function in Windows API to toggle the "Show hidden files, folders and drives" option in Windows Explorer (Tools >> Folder Options... >> View tab).

I know of a related registry key, but changing that would not have immediate effect. The key is: HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Expl开发者_JS百科orer/Advanced/Hidden

Trying to do this from C#, but the question is not language-specific.


You could try the options the OP in this thread suggests, that is:

Either

 SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);

or

 RefreshPolicyEx(False, RP_FORCE);

or

 SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, integer(pchar('Policy')), SMTO_NORMAL or SMTO_ABORTIFHUNG, 5000, c1);

These are not in the .NET C# API, so you'll have to use DllImport

Edit: formatting


In addition to the comment I've added to the original question - if you're doing this so that, for instance, the OpenFileDialog you're about to pop open shows these files - don't do it.

In that case, you're better P/Invoking GetOpenFileName, and setting the appropriate option (OFN_FORCESHOWHIDDEN (see enum for a related subject) in the flags of the OpenFileName structure.

That way you're only affecting your application, at the appropriate time


I know of no API, but the registry key is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden. From experimentation, it seems a value of 1 means show and a value of 2 means hide.


SHGetSetSettings

SHELLSTATE Structure fShowAllObjects BOOL TRUE to show all objects, including hidden files and folders. FALSE to hide hidden files and folders.

fShowSysFiles BOOL TRUE to show system files, FALSE to hide them.

Spy++ says a WM_SETTINGCHANGE is sent to the explorer windows.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号