GetSaveFileNameW Function
- Header:
comdlg32.h - Library:
comdlg32.lib - DLL:
comdlg32.dll
The GetSaveFileNameW function displays the Save As dialog box, which allows the user to specify the drive, directory, filename, and extension for the file to be saved.
Syntax
BOOL GetSaveFileNameW(
LPSAVEDIALOGW lpofn
);
Parameters
lpofn- [in, out] A pointer to a
SAVEFILENAMEWstructure that contains information used to initialize the dialog box. ThelpfnHookmember of this structure can be a pointer to a hook procedure. ThelpfnOwnerDrawmember can be a pointer to an owner-draw callback function.
Return Value
If the user specifies a filename and clicks the OK button, the return value is nonzero. The nFileOffset member of the SAVEFILENAMEW structure indicates the starting position of the filename in the lpstrFile buffer, and the nFileExtension member indicates the starting position of the file extension.
If the user cancels the dialog box or an error occurs, the return value is zero. To get extended error information, call CommDlgExtendedError.
Remarks
The SAVEFILENAMEW structure must be initialized before passing it to GetSaveFileNameW. At a minimum, you must set the lStructSize member to the size of the structure, set the hwndOwner member to the handle of the owner window, and set the lpstrFile member to point to a buffer that can hold a null-terminated filename string. The size of this buffer should be sufficient to hold the longest possible filename, including the null terminator.
The dialog box template specified by the lpstrTemplateName member must be a dialog box resource of the same type as the dialog box being displayed. For GetSaveFileNameW, this is a OFN_EXPLORER or OFN_ENABLETEMPLATE dialog box resource.
GetSaveFileName function is a generic alias for the wide-character GetSaveFileNameW function.
Requirements
| Minimum supported client | Windows 2000 Professional [desktop apps only] |
| Minimum supported server | Windows 2000 Server [desktop apps only] |
| Target Platform | Windows |
| Header | comdlg32.h (include Windows.h) |
| Library | comdlg32.lib |
| DLL | comdlg32.dll |