Locate Directories Using the Application Programming Interface Not Hard-Coded Paths [Application Compatibility Guide] 

 
Platform SDK: Application Compatibility Guide

Locate Directories Using the Application Programming Interface Not Hard-Coded Paths

Your application should use the functions SHGetFolderPath, GetWindowsDirectory, GetSystemDirectory, and GetTempPath to find directories used by Windows. Applications that use hard-coded paths to specific locations, may not work on other versions of Windows because the location of folders and directories can change with different versions of Windows.

For example, on Windows 95 and Windows 98, the My Documents folder is located at the root of the C or D drive. Windows NT 4.0 enabled users to create personal folders on a per-user basis, which were located in the Windows system directory: %windir%\profiles\user\personal. A default installation of Windows 2000 Professional puts the My Documents folder on the system drive at: \Documents and Settings\user\My Documents. In many enterprise situations, the user's My Documents folder may be moved off the local machine to a network share to makes it available to the user from anywhere by using roaming profiles.

To find shell folders such as My Documents, use SHGetFolderPath to get the path. You can use it on Windows 95, Windows 98, or any Windows platform. For an example of how to get a folder, see SHGetFolderPath.

When you use Windows Installer to manage the setup of your application, the installer can search for a particular file or directory during an installation. For more information, see Searching for Existing Applications, Files, Registry Entries or .ini File Entries. in Windows Installer.

  
  Last updated: April 2004  |  What did you think of this topic?  |  Order a Platform SDK CD
  © 2004 Microsoft Corporation. All rights reserved. Terms of use.