March 1999
How Windows locates files
by Kent Reisdorph
In the article, "Spawning external applications," we passed
filenames or document files to the WinExec, ShellExecute, and CreateProcess
functions. These functions allow you to pass a fully qualified path and
filename or just the filename itself. If just a filename is passed, Windows
will attempt to locate the file. Windows searches for the file in the following
order:
- The directory where the application resides.
- The current directory.
- The Windows system directory (SYSTEM for Windows 95 and 98, and SYSTEM32 for
Windows NT).
- The Windows 16-bit system directory, usually called SYSTEM (NT only).
- The Windows root directory.
- The directories on the system path (listed in the PATH environment
variable).
If the application being spawned doesn't reside in any of the directories
listed above, you must fully qualify the path and filename to the application.