SetCurrentDirectory

  BOOL SetCurrentDirectory(lpszCurDir)    
  LPTSTR lpszCurDir; /* name of new current directory */

The SetCurrentDirectory changes the current directory for the current process.

Parameters

lpszCurDir

Points to a null-terminated string that specifies the path to the new current directory. This parameter may be a relative path or a fully-qualified path. In either case, the fully-qualified path of the specified directory is calculated and is stored as the current directory.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

Each process has a single current directory. A current directory is made up of two parts:

A disk designator (either a drive letter followed by a colon, or a server name and share name: “\\servername\sharename”).

A directory on the disk designator.

For functions that manipulate files, the filenames may be relative to the current directory. A filename is relative to the current directory if it does not begin with a disk designator or a directory name separator, such as a backslash (\). If the filename begins with a directory name separator, then it is relative to the root directory of the current disk designator. If a filename begins with a disk designator, then it is a fully-qualified path.

The SetCurrentDirectory function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

GetCurrentDirectory