GetCurrentDirectory Function

Retrieves the current working directory of the calling process.

Syntax

DWORD GetCurrentDirectory(
                  DWORD  nBufferLength,
                  LPTSTR lpBuffer
                );

Parameters

Parameter Description
nBufferLength The size, in characters, of the buffer pointed to by lpBuffer.
lpBuffer A pointer to a buffer that receives a null-terminated string that specifies the drive and path of the current directory.

Return Value

If the function succeeds, the return value is the length, in characters, of the string copied to lpBuffer, not including the terminating null character. If the buffer pointed to by lpBuffer is not large enough to contain the current directory, the return value is the required buffer size in characters, including the terminating null character.

Remarks

The current working directory is the directory that the process uses for file operations if a full path is not specified.

To get the current directory for a drive other than the current drive, use the GetFullPathName function.

Note: For a list of common error codes, see System Error Codes.

Requirements

Component Value
Minimum supported client Windows XP
Minimum supported server Windows Server 2003
Target Platform Windows
Header Winbase.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also