GetSaveFileName

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function creates a system-defined dialog box that enables the user to specify a filename to which to save.

Syntax

BOOL GetSaveFileName( 
  LPOPENFILENAME lpofn
);

Parameters

  • lpofn
    [in] Long pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetSaveFileName returns, this structure contains information about the user's file selection.

Return Value

A value of 0 or 6 indicates that the user canceled or closed the Save dialog box or that an error occurred.

  • On Windows Mobile Standard, if the user canceled or closed the Save dialog box, GetSaveFileName sets the error code to 6, so when the application calls GetLastError to retrieve the most recent error code, it returns an error code value of ERROR_INVALID_HANDLE (numerical value 6).
  • On Windows Mobile Professional, GetSaveFileName does not change the last error code, so GetLastError returns an error code value of 0.

Any other value indicates that the user specified a file name and clicked the OK button. The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and file name specified by the user.

To retrieve extended error information, call GetLastError. GetSaveFileName sets only the error codes ERROR_INVALID_HANDLE, ERROR_INVALID_PARAMETER, and ERROR_OUTOFMEMORY.

Remarks

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

Windows Embedded CE modifies the meaning of the following members of the OPENFILENAME structure when it is passed into GetOpenFileName.

  • Flags
    If this member is set to the OFN_PROJECT value, the GetOpenFileName function opens the Folder dialog box. Otherwise, the function opens the Open dialog box.
  • lpstrFile
    When GetOpenFileName returns successfully, this member is used to retrieve full path of the selected file name.
  • lpstrFileTitle
    When GetOpenFileName returns 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 GetOpenFileName function is called, Windows Embedded CE adds the following pre-specified 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

Reference

GetOpenFileName
WM_CTLCOLORDLG
OPENFILENAME

Other Resources

GetLastError