how to programatically "hide/show extensions for known file types"?

Reply

Join Date: Apr 2007
Posts: 84
Reputation: phalaris_trip is an unknown quantity at this point 
Solved Threads: 5
phalaris_trip's Avatar
phalaris_trip phalaris_trip is offline Offline
Junior Poster in Training

how to programatically "hide/show extensions for known file types"?

 
0
  #1
Jul 24th, 2009
Hi,
This seems like a really simple question.
Most of the time I choose to show extensions for known file types, but sometimes (most notably when renaming files by hand) it is convenient to hide them.
This is achived by checking the checkbox at:
Tools -> Folder Options -> View -> Hide extensions for know file types.

Now what I would like to do is write a really simple app which will change this for me instantly.
So maybe when I run the app once it enables the setting and when I run it again it disables the setting. Really simple.

I'm guessing there is a DWORD somewhere in the registry or something to that effect. How would I got about doing this programmatically?

PS. I would prefer to do this in C# if possible.

Thanks in advance,
.iMMersE your soUL in LOVE.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 19
Reputation: icyshout is an unknown quantity at this point 
Solved Threads: 1
icyshout icyshout is offline Offline
Newbie Poster

Re: how to programatically "hide/show extensions for known file types"?

 
0
  #2
Jul 24th, 2009
its not easy enough to just do it manually?

if i was making an application to do this i would use autohotkey or autoit to just basically do a macro...
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 84
Reputation: phalaris_trip is an unknown quantity at this point 
Solved Threads: 5
phalaris_trip's Avatar
phalaris_trip phalaris_trip is offline Offline
Junior Poster in Training

Re: how to programatically "hide/show extensions for known file types"?

 
0
  #3
Jul 24th, 2009
Thanks for fast reply!

Originally Posted by icyshout View Post
its not easy enough to just do it manually?
Yes, but it is is even easier to have a once click app in my taskbar.
Also, for files on the desktop, folder options are not immediately accessible.
Also, I like learning new things, and lastly, I have OCD.

Originally Posted by icyshout View Post
if i was making an application to do this i would use autohotkey or autoit to just basically do a macro...
I would rather not use a third party app for such a simple task. I'm sure in the end it just comes down to changing a single value somewhere in the registry...
.iMMersE your soUL in LOVE.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 84
Reputation: phalaris_trip is an unknown quantity at this point 
Solved Threads: 5
phalaris_trip's Avatar
phalaris_trip phalaris_trip is offline Offline
Junior Poster in Training

Re: how to programatically "hide/show extensions for known file types"?

 
0
  #4
Jul 24th, 2009
Woo, I figured it out.

Works perfectly (in XP anyway).

It really is this simple:

using Microsoft.Win32;
namespace ShowHideExtensions
{
	class Program
	{
		static void Main()
		{
			RegistryKey key =
				Registry.CurrentUser.CreateSubKey(
				"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced");

			if ((int)key.GetValue("HideFileExt") == 0)
			{
				key.SetValue("HideFileExt", 1);
			}
			else
			{
				key.SetValue("HideFileExt", 0);
			}
		}
	}
}

Problem is that it doesn't update instantly... you have to hit refresh (or close windows explorer and open it again).

I wonder if there's a way to force the OS to invalidate or something...
.iMMersE your soUL in LOVE.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: fozbat is an unknown quantity at this point 
Solved Threads: 0
fozbat fozbat is offline Offline
Newbie Poster

Re: how to programatically "hide/show extensions for known file types"?

 
0
  #5
Jul 24th, 2009
Surely you could acheive this with a simple .reg file on the desktop

Foz
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 84
Reputation: phalaris_trip is an unknown quantity at this point 
Solved Threads: 5
phalaris_trip's Avatar
phalaris_trip phalaris_trip is offline Offline
Junior Poster in Training

Re: how to programatically "hide/show extensions for known file types"?

 
0
  #6
Jul 24th, 2009
Originally Posted by fozbat View Post
Surely you could acheive this with a simple .reg file on the desktop

Foz
I have no idea how that works. Will look into it, thanks for the reply.
.iMMersE your soUL in LOVE.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,301
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 588
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: how to programatically "hide/show extensions for known file types"?

 
0
  #7
Jul 24th, 2009
Originally Posted by phalaris_trip View Post
I wonder if there's a way to force the OS to invalidate or something...
Invalidate just causes the invalidated region of the screen/form to be redrawn. You need explorer to truly do a refresh of the data subset to display the files.

Refreshing explorer:
http://social.msdn.microsoft.com/For...b-4580be9b344f
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Windows NT / 2000 / XP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC