Why is there a separate GetSystemDirectory function?

Date:October 8, 2004 / year-entry #362
Tags:history
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20041008-00/?p=37623
Comments:    18
Summary: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 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.


Comments (18)
  1. mschaef says:

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

  2. Ben Cooke says:

    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.

  3. Cooney says:

    Nope. Netware and the other raft of lans ran under DOS, so windows basically depended on that for its networking.

  4. Marco says:

    another reason could be mono. on a linux system this will look completely differnet!

    bye marco

  5. lowercase josh says:

    Too bad there’s no environment variable for it though.

  6. null says:

    I did that. We had the whole building running the same system files. Seems backward to many today.

    system on network

    files on local

  7. Miles Archer says:

    So would it be unwise to assume for the future that the System32 is the directory? Is it still System32 for 64bit Windows?

  8. Cooney says:

    Probably. Would you rather hardcode your apps now and have them break later?

  9. Mike Dunn says:

    I’m pretty sure Raymond mentioned a while back that in Win64 it’s still called "system32" to ensure (wait for it…) backward compatibility.

  10. Scott says:

    So we know why the function exists. Should we use it rather than the variable?

  11. Raymond Chen says:

    Keep using the function.

  12. Jordan Russell says:

    Is there any valid reason to use SHGetFolderPath(…, CSIDL_SYSTEM, …) in place of GetSystemDirectory?

  13. Raymond Chen says:

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

  14. Anonymous Coward says:

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

  15. Actually it doesn’t force you to validate – it just offers validation as an option.

  16. Michael says:

    I miss those days. Why cannot one run NT from a server?

  17. Anonymous Coward says:

    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.

  18. mb says:

    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 ‘system32logfiles’ 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?)

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index