Skip to content

Latest commit

 

History

History
142 lines (87 loc) · 6.02 KB

nf-commdlg-getopenfilenamew.md

File metadata and controls

142 lines (87 loc) · 6.02 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name req.apiset
NF:commdlg.GetOpenFileNameW
GetOpenFileNameW function (commdlg.h)
Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened. (Unicode)
GetOpenFileName
GetOpenFileName function [Dialog Boxes]
GetOpenFileNameW
_win32_GetOpenFileName
_win32_getopenfilename_cpp
commdlg/GetOpenFileName
commdlg/GetOpenFileNameW
dlgbox.getopenfilename
winui._win32_getopenfilename
dlgbox\getopenfilename.htm
dlgbox
VS|winui|~\winui\windowsuserinterface\userinput\commondialogboxlibrary\commondialogboxreference\commondialogboxfunctions\getopenfilename.htm
12/05/2018
GetOpenFileName, GetOpenFileName function [Dialog Boxes], GetOpenFileNameA, GetOpenFileNameW, _win32_GetOpenFileName, _win32_getopenfilename_cpp, commdlg/GetOpenFileName, commdlg/GetOpenFileNameA, commdlg/GetOpenFileNameW, dlgbox.getopenfilename, winui._win32_getopenfilename
commdlg.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
GetOpenFileNameW (Unicode) and GetOpenFileNameA (ANSI)
Comdlg32.lib
Comdlg32.dll
Windows
19H1
GetOpenFileNameW
commdlg/GetOpenFileNameW
c++
APIRef
kbSyntax
DllExport
Comdlg32.dll
ext-ms-win-shell-comdlg32-l1-1-0.dll
GetOpenFileName
GetOpenFileNameA
GetOpenFileNameW
ext-ms-win-shell-comdlg32-l1-1-1 (introduced in Windows 10, version 10.0.14393)

GetOpenFileNameW function

-description

[Starting with Windows Vista, the Open and Save As common dialog boxes have been superseded by the Common Item Dialog. We recommended that you use the Common Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]

Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened.

-parameters

-param unnamedParam1 [in, out]

Type: LPOPENFILENAME

A pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetOpenFileName returns, this structure contains information about the user's file selection.

-returns

Type: BOOL

If the user specifies a file name and clicks the OK button, the return value is nonzero. The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and file name specified by the user.

If the user cancels or closes the Open dialog box or an error occurs, the return value is zero. To get extended error information, call the CommDlgExtendedError function, which can return one of the following values.

-remarks

The Explorer-style Open dialog box provides user-interface features that are similar to the Windows Explorer. You can provide an OFNHookProc hook procedure for an Explorer-style Open dialog box. To enable the hook procedure, set the OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the address of the hook procedure in the lpfnHook member.

Windows continues to support the old-style Open dialog box for applications that want to maintain a user-interface consistent with the old-style user-interface. To display the old-style Open dialog box, enable an OFNHookProcOldStyle hook procedure and ensure that the OFN_EXPLORER flag is not set.

To display a dialog box that allows the user to select a directory instead of a file, call the SHBrowseForFolder function.

Note, when selecting multiple files, the total character limit for the file names depends on the version of the function.

  • ANSI: 32k limit
  • Unicode: no restriction

Examples

For an example, see Opening a File.

Note

The commdlg.h header defines GetOpenFileName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

CommDlgExtendedError

Common Dialog Box Library

Conceptual

GetSaveFileName

OFNHookProc

OFNHookProcOldStyle

OPENFILENAME

Other Resources

Reference

SHBrowseForFolder