GetFileNameFromBrowse function (shlobj.h)
[This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable in subsequent versions of Windows.]
Creates an Open dialog box so that the user can specify the drive, directory, and name of a file to open.
Syntax
BOOL GetFileNameFromBrowse(
[in, optional] HWND hwnd,
[in, out] PWSTR pszFilePath,
UINT cchFilePath,
[in, optional] PCWSTR pszWorkingDir,
[in] PCWSTR pszDefExt,
[in, optional] PCWSTR pszFilters,
[in, optional] PCWSTR pszTitle
);
Parameters
[in, optional] hwnd
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.
[in, out] pszFilePath
Type: PWSTR
A null-terminated Unicode string that contains a file name used to initialize the File Name edit control. This string corresponds to the OPENFILENAME structure's lpstrFile member and is used in exactly the same way.
cchFilePath
Type: UINT
The number of characters in pszFilePath, including the terminating null character.
[in, optional] pszWorkingDir
Type: PCWSTR
The fully qualified file path of the initial directory. This string corresponds to the OPENFILENAME structure's lpstrInitialDir member and is used in exactly the same way.
[in] pszDefExt
Type: PCWSTR
A null-terminated Unicode string that contains the default file name extension. This extension is added to pszFilePath if the user does not specify an extension. The string should not contain any '.' characters. If this string is NULL and the user fails to type an extension, no extension is appended.
[in, optional] pszFilters
Type: PCWSTR
A null-terminated Unicode string that defines the filter. This string corresponds to the OPENFILENAME structure's lpstrFilter member and is used in exactly the same way.
[in, optional] pszTitle
Type: PCWSTR
A null-terminated Unicode string that is placed in the title bar of the dialog box. If this value is NULL, the system uses the default title.
Return value
Type: BOOL
If the user specifies a file name and clicks OK, the return value is TRUE. The buffer that pszFilePath points to contains the full path and file name that the user specifies. If the user cancels or closes the Open dialog box or an error occurs, the return value is FALSE.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | shlobj.h (include Shlobj.h) |
Library | Shell32.lib |
DLL | Shell32.dll (version 5.0 or later) |