Mucking with the System Directory - Keep Out


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:

  • Some corporate users on Windows 2000 and XP don’t have access to the system directory. Do you want them to be unable to install your software?

  • You run into major versioning issues, even with your own DLLs, if people install multiple versions of your software.

  • You might inadvertently name your DLL the same name as some other company’s DLL that’s already there. That would cause their software to malfunction. But what do you care? What if the user installs their software after installing yours, causing your software not to function?

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.)




Designing Highly Useable Software
Designing Highly Useable Software
ISBN: 0782143016
EAN: 2147483647
Year: 2003
Pages: 114

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net