" />
« February 2004 | Main | April 2004 »
Notice a few things:
* The spacings are marked with dotted lines. These appear when your control snaps to the correct position, say to the edge of a dialog or to another control, both veritcally and horizontally.
* The red baseline is to line up text in controls that have different heights! How cool is that?!
On that last point, I wonder how your own custom control can play nice in Whidbey and integrate with this feature. Perhaps you implement an interface or provide a baseline property that allows the environment to adapt.
Chris Sells tells us to Avoid the GAC.
In my previous DeepSize post, my instructions include using gacutil which, of course, installs DeepSize into the GAC. While my little application will never get updated by another party and possibly installed over the a version you may have already installed (wishful thinking), I suppose I should reconsider my choice to use the GAC for DeepSize.
After doing some research, it looks like I have to put the explorer extension in the GAC. I tried various configurations such as placing DeepSize.dll in a directory on my SYSTEM path and calling regasm. I understand that COM doesn't deal with the path since explicit references to the path a COM DLL is located is hard-wired into the registry when regsvr32.exe is invoked on the library. However, none of those scenarios worked.
I Googled for a few more articles on the topic of Explorer extensions and one link in particular corroborated the original Code Project article's instructions on placing the Explorer extension in the GAC. See Extending Explorer with Band Objects using .NET and Windows Forms (also on Code Project).
Furthermore, I'm beginning to understand the role of RegAsm.exe as opposed to regsvr32.exe. You can't register a .NET DLL using regsvr32.exe since a .NET DLL doesn't support the old COM registration functions. RegAsm.exe works through COM Interop, which, while it exposes .NET objects as COM objects, it doesn't do it through old fashion means of DllRegisterServer() and DllUnregisterServer().
I definitely dig having the Chris Sells piece in my mind. However, I'm also glad I've gained a little personal experience on when to do and not to do something.
Sometime last summer, I saw a cool article on the Code Project called "Explorer column handler shell extension in C#":http://www.codeproject.com/csharp/columnhandler.asp.
While I had some desire to see MD5 checksums of certain production files, I was more excited by the idea this article gave me. What if I modified the code to provide a "deep size" column in Explorer that would show the total size of all files in a directory? To me, this is a very useful thing.
So, I went and wrote the thing and it officially became my first C# program... or first C# Class, since I just modified the existing assembly.
I have a pre-built version here, along with my source (which is a modified version of the Code Project original).
I didn't find any kind of copyright in the source files, so I didn't include anything in mine. I hope I didn't miss anything there and I offer apologies in advance to the original author if I did.
To install it, I like to copy if to my Global Assembly Cache. Just execute:
gacutil /i DeepSize.dll
Then, you need to register the assembly as a COM server via:
RegAsm.exe DeepSize.dll (register the version in your GAC).
You may need to restart explorer by logging out than back in. Once you do, right-click on any explorer file ListView (aside from My Computer and My Network Places) and select "More...". "DeepSize" and "MD5 Hash" should be new choices.
I exclude certain directories from consideration, since it's well known that they are big. These are directories "ending" in:
* "PROGRAM FILES"
* "DOCUMENTS AND SETTINGS"
* "WINDOWS"
* "WIN98"
* "WINME"
* "I386"
* "WINNT"
When I included those, performance suffered and the other directories I was interested in had to wait until those monsters were calculated.
Feedback welcome. If you want the rest of the Visual Studio files, let me know and I'll provide them.
Enjoy!
string[] files = new string[args.Length - 1]; Array.Copy(args, 1, files, 0, files.Length);-- To this: --
string[] files = Directory.GetFiles(@".", args[1]);-- To make this code production quality, of course, I shouldn't have to specify "." as the current directory. If args[1] specifies a directory, I should extract it and use that. Also, it wouldn't be hard to accept multiple files as Gus Perez did originally, allowing each argument to be a single file or a filespec (myfile.txt *.log *.xml)
Wow, that recent picture looks just like this one generated (for today) by the Solar System Generator... neat!
Update: Category changed
Most people that know me know that my memory sucks ass. I'm finding my blog a useful way to jot down links and ideas that I'd like to revisit at some point. This represents a synergy between keeping a tab on a topic and letting my readers know about what I'm interested in. Granted, I think I have about two readers, but I won't be deterred! That's why I just posted my link on "how to submit an article to MSDN":http://www.primordia.com/blog/archives/000038.html. I may want to do that someday. "Eric Gunnerson":http://blogs.msdn.com/ericgu/ (A C# blogger) just posted a link to a Warthog game on Bungie's Web site. In case you don't realize, "Bungie":http://www.bungie.com is the Game developer for "Halo":http://halo.bungie.net/, best game EVER. The link is dead, so I'll have to try it in a few days. How convenient the link is now on my blog.
to this<$MTEntryTitle$>
I also added some accessibility features, such as language (English) as recommended by this "Dive Into Accessibility":http://diveintoaccessibility.org/ interesting online book.<$MTEntryTitle$>