GetCommDlgDir

Retrieves the current directory for a directory-selection dialog box.

Syntax

BOOL GetCommDlgDir(
  HWND   hDlg,
  LPWSTR lpPath,
  int    nSize
);

Parameters

  • hDlg: A handle to the dialog box.
  • lpPath: A pointer to a null-terminated string that receives the full path of the current directory.
  • nSize: The size, in characters, of the buffer pointed to by lpPath.

Return Value

  • If the function succeeds, the return value is nonzero.
  • If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The GetCommDlgDir function is used to retrieve the current directory from a directory-selection dialog box that was created using the ChooseDir function.

This function is part of the COMdlg32.dll library, which provides common dialog box functionality.

The lpPath buffer must be large enough to hold the null-terminated string representing the directory path, including the null terminator. The nSize parameter specifies the total size of this buffer.

Before calling GetCommDlgDir, you should ensure that the dialog box handle (hDlg) is valid and that the dialog box is currently active.

Requirements

Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header CommDlg.h
Library Comdlg32.lib
DLL Comdlg32.dll
Unicode and ANSI versions GetCommDlgDirW (Unicode) and GetCommDlgDirA (ANSI)

See Also

Common Dialog Box Functions
ChooseDir