Designing Highly Useable Software

Mucking with the System Directory—Keep Out!

If you’re creating Windows software, here’s a word of wisdom:

SUGGESTION

Stay out of my Windows directories!!!

Don’t dump garbage—er, I mean files—in my Windows directory, or in my System directory, or in the System32 directory, or anywhere under the Windows directory (which I collectively call the system directory). I know a lot of people like to put DLLs there in the belief that their software won’t function otherwise. But that’s not true. If you put your DLLs in the same directory as your executable, Windows will find them. (At least one shareware program I downloaded put a file called SYS.DLL in my system directory; it took me all of 10 seconds to figure out that this file was a text file containing a number that represented how many times I could run the program.)

There are lots of good reasons to avoid the system directory beyond me griping about it:

If you’re working with the new Microsoft .NET system, Microsoft has given you permission to put assemblies (which are really DLLs that make use of the managed system) in the system directory inside the global assembly cache. The global assembly cache is a set of directories under WINDOWS\assembly\gac. This directory includes various version directories; that allows you to have different versions of your own assemblies. However, before you get all gung ho about putting your assemblies in the global cache, remember that the only reason you should do this is if your assemblies will be used by multiple applications. Otherwise, put them in the same directory as your executable, and Windows will find them just fine.

Tip

Check out this link for more information on assembly placement: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconassemblyplacement.asp. (If you don’t want to type all that in, go to http://msdn.microsoft.com/library/default.asp and search on the string Assembly Placement.)

Категории