Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function creates a system-defined dialog box that enables the user to select a file to open.

Syntax

BOOL GetOpenFileName( 
  LPOPENFILENAME 
lpofn
);

Parameters

lpofn

[in] Long pointer to an OPENFILENAMEstructure that contains information used to initialize the dialog box. When GetOpenFileNamereturns, this structure contains information about the user's file selection.

Return Value

Nonzero indicates that the user specified a file name and clicked the OKbutton. The buffer pointed to by the lpstrFilemember of the OPENFILENAMEstructure contains the full path and filename specified by the user.

Zero indicates that the user canceled or closed the Opendialog box or that an error occurred. To get extended error information, call GetLastError. GetOpenFileNamesets only the ERROR_INVALID_PARAMETER and ERROR_OUTOFMEMORY errors.

Remarks

Not all members of the OPENFILENAMEstructure are defined in Windows Embedded CE. For information about the defined members, see the reference topic for the OPENFILENAMEstructure.

Windows Embedded CE modifies the meaning of the following members of the OPENFILENAMEstructure when it is passed into the GetOpenFileNamefunction.

Flags

If this member is set to the OFN_PROJECT value, the GetOpenFileNamefunction opens the Folderdialog box. Otherwise, the function opens the Opendialog box.

lpstrFile

When GetOpenFileNamereturns successfully, this member is used to retrieve full path of the selected file name.

lpstrFileTitle

When GetOpenFileNamereturns successfully, this member is used to retrieve the project folder name only.

lpstrInitialDir

Pointer to a string that receives the initial folder name, but not the full path name.

When the GetOpenFileNamefunction is called, Windows Embedded CE adds the following prespecified undefined members:

  • lpstrCustomFilter

  • lpstrMaxCusFilter

  • lpstrDefExtension

  • lCustData

  • lpfnHook

  • lpstrTemplateName

Requirements

Header commdlg.h
Library Fileopen.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also