.NET and "hide extensions for known file types"

R

Richard Rudie

Anyone know of a proper .NET way to get the state of the user's "hide
extensions for known file types" setting? Or should I read the value
from the Registry directly
(HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt)?
 
R

Richard Rudie

I'm not sure you can call it a ".NET way", but there's a native API to
retrieve these settings called SHGetSettings (use the
SSF_SHOWEXTENSIONS flag).

That sounds like a better way than reading the Registry. And probably
much less hassle than IShellDispatch4::GetSetting.

I see the SHELLFLAGSTATE struct that SHGetSettings uses is a 16-bit
group of bitfields. You can't do bitfields in C# / PInvoke, can you? I
would need to declare SHGetSettings with its first parameter as "out
UInt16" and do bitwise operations on the value, yes? Like so:

UInt16 u;
SHGetSettings( out u, SSF_SHOWEXTENSIONS );
bool bShowExt = ( ( u & 0x0002 ) != 0 );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top