Welcome to MSDN Blogs Sign in | Join | Help

Why is there a separate GetSystemDirectory function?

If the system directory is always %windir%\SYSTEM32, why is there a special function to get it?

Because it wasn't always that.

For 16-bit programs on Windows NT, the system directory is %windir%\SYSTEM. That's also the name of the system directory for Windows 95-based systems and all the 16-bit versions of Windows.

But even in the 16-bit world, if it was always %windir%\SYSTEM, why have a function for it?

Because even in the 16-bit world, it wasn't always %windir%\SYSTEM.

Back in the old days, you could run Windows directly over the network. All the system files were kept on the network server, and only the user's files were kept on the local machine. What's more, every single computer on the network used the same system directory on the server. There was only one copy of USER.EXE, for example, which everybody shared.

Under this network-based Windows configuration, the system directory was a directory on a server somewhere (\\server\share\somewhere) and the Windows directory was a directory on the local machine (C:\WINDOWS). Clients did not have write permission into the shared system directory, but they did have permission to write into the Windows directory.

That's why GetSystemDirectory is a separate function.

Published Friday, October 08, 2004 6:57 AM by oldnewthing
Filed under:

Comments

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 8:04 AM by mschaef
"Back in the old days, you could run Windows directly over the network. "

Was this true for Windows for Workgroups too? I thought the filesharing itself depended on Windows to work.

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 8:11 AM by Ben Cooke
mschaef,
It was possible to "mount" SMB filesystems to DOS drive letters from the DOS command prompt before Windows was loaded. I often made use of this feature since back in those days I wasn't really much of a Windows fan and preferred to do things in DOS.

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 8:13 AM by Cooney
Nope. Netware and the other raft of lans ran under DOS, so windows basically depended on that for its networking.

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 8:25 AM by Marco
another reason could be mono. on a linux system this will look completely differnet!

bye marco

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 10:16 AM by lowercase josh
Too bad there's no environment variable for it though.

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 10:27 AM by null
I did that. We had the whole building running the same system files. Seems backward to many today.

system on network
files on local

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 10:36 AM by Miles Archer
So would it be unwise to assume for the future that the System32 is the directory? Is it still System32 for 64bit Windows?

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 11:02 AM by Cooney
Probably. Would you rather hardcode your apps now and have them break later?

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 11:21 AM by Mike Dunn
I'm pretty sure Raymond mentioned a while back that in Win64 it's still called "system32" to ensure (wait for it...) backward compatibility.

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 1:31 PM by Scott
So we know why the function exists. Should we use it rather than the variable?

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 3:28 PM by Raymond Chen
Keep using the function.

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 3:43 PM by Jordan Russell
Is there any valid reason to use SHGetFolderPath(..., CSIDL_SYSTEM, ...) in place of GetSystemDirectory?

# re: Why is there a separate GetSystemDirectory function?

Friday, October 08, 2004 3:51 PM by Raymond Chen
CSIDL_SYSTEM just calls GetSystemDirectory. It's there more for completeness than to provide new functionality. (For example, since you can use CSIDL values in INF files, this lets you use the system directory from an INF file.)

# Application Compatibility Kit

Friday, October 08, 2004 8:08 PM by Anonymous Coward
Raymond,

How complete is the Application Compatibility Toolkit for stuff like this? (I used to be guilty of using the registry for getting "My Documents" until your post on the subject since you actually explained why things were the way they were :-)

For those who don't know, the ACT is supposed to check your app by running it and seeing what you do wrong. It is at http://www.microsoft.com/windows/appcompatibility/toolkit.mspx

For some bizarre reason the download page now tries to make you verify that your copy of Windows is genuine, but you can bypass that. (My copy was bought at the MS employee store so it had better be genuine :-)

# re: Why is there a separate GetSystemDirectory function?

Saturday, October 09, 2004 6:33 AM by Larry Osterman
Actually it doesn't force you to validate - it just offers validation as an option.

# re: Why is there a separate GetSystemDirectory function?

Monday, October 11, 2004 1:28 PM by Michael
I miss those days. Why cannot one run NT from a server?

# Running NT from a server

Monday, October 11, 2004 8:06 PM by Anonymous Coward
You can run NT from a server. The product you want is Windows XP Embedded, where you can choose exactly what OS components you want, and can run off flash or over the network, as well as a good old fashioned hard disk.

# re: Why is there a separate GetSystemDirectory function?

Sunday, October 17, 2004 12:32 AM by mb
Any comments on the 'immutability' of the system directory?

Once got a complaint about a Win3.1 program which wrote data to the system directory, we had to change it to the Windows directory (it was appropriate there, though I forget the data).

So now it's always irksome to find that there is a 'system32\logfiles' directory. How can you have a writable directory inside what is potentially a read-only and/or remote network shared directory? (I'm sure it's because the requirements have changed, but when?)
New Comments to this post are disabled
 
Page view tracker