CommDlgExtendedError

The CommDlgExtendedError function retrieves the extended error value for the last Common Dialog Box Library (Comdlg32.dll) function call.

DWORD CommDlgExtendedError(void);

Parameters

This function has no parameters.

Return Value

The return value is the extended error value.

This value can be one of the following:

  • 0: No error occurred.
  • One of the following common dialog box error values.

Remarks

The common dialog box functions set the extended error value when an error occurs. You can call CommDlgExtendedError to retrieve this value.

When a common dialog box function returns FALSE, you can call CommDlgExtendedError to get more information about the error.

Common dialog box error codes are defined in the CommDlg.h header file.

Error Codes

Common Dialog Box Error Codes

  • CDERR_DIALOGFAILURE: (0x0001) The dialog function failed due to a memory allocation error or other internal error.
  • CDERR_FINDRESFAILURE: (0x0002) The function failed to find a specified resource.
  • CDERR_LOADRESFAILURE: (0x0003) The function failed to load a specified resource.
  • CDERR_LOCKRESFAILURE: (0x0004) The function failed to lock a specified resource.
  • CDERR_MEMALLOCFAILURE: (0x0005) The function failed to allocate memory.
  • CDERR_MEMLOCKFAILURE: (0x0006) The function failed to lock memory.
  • CDERR_NOHINSTANCE: (0x0007) A required instance handle (hinstance) was not provided.
  • CDERR_NOHOPENFILE: (0x0008) The OPENFILENAME structure is invalid.
  • CDERR_NOTEMPLATE: (0x0009) No valid template was specified.
  • CDERR_STRUCTNOTINITIALIZED: (0x000A) The lpstrFile member is NULL.
  • CDERR_UNREGISTERMSGFILTER: (0x0004) An error occurred attempting to unregister a window procedure.
  • CDERR_GETMONIKERNAMESFAILURE: (0x000B) The system cannot retrieve the list ofmoniker names.
  • CDERR_PROCINITIALIZATIONFAILURE: (0x000C) The system cannot initialize the subclass window procedure.
  • CDERR_XMLPARSEERROR: (0x000D) The system cannot parse the XML file.
  • CDERR_MOREDATA: (0x000E) More data is available than can be returned by the function.
  • CDERR_INVALIDFILENAME: (0x000F) The specified filename is invalid.
  • FNERR_BUFFERTOOSMALL: (0x1001) The buffer pointed to by lpstrFile is too small.
  • FNERR_INVALIDCATALOG: (0x1002) The catalog file is not valid.
  • FNERR_INVALIDDISPLAYNAME: (0x1003) The specified display name is not valid.
  • FNERR_NOTRANSLATION: (0x1004) The specified translation is not valid.
  • PDERR_STRUCTUREVALIDATION: (0x1001) The PRINTDLG structure is invalid.
  • PDERR_DEFAULTDICTIONARYFLT: (0x1002) The default dictionary is not found.
  • PDERR_INITPRINTRESFLT: (0x1003) The system cannot find a printer driver that supports the specified functionality.
  • PDERR_NOTSUPPORTED: (0x1004) The printer driver does not support the specified functionality.
  • C1_PRINTERNOTFOUND: (0x1005) The printer was not found.
  • C1_CREATEFONTFAILURE: (0x1006) The system cannot create the font.
  • C1_CHOOSEFONTFAILED: (0x1007) The ChooseFont function failed.
  • PDERR_NODEFAULTPRINTER: (0x1008) No default printer is available.
  • PDERR_INVALIDDEVICE: (0x1009) The specified device is not valid.
  • PDERR_PRINTERNOTFOUND: (0x100A) The printer was not found.
  • PDERR_PROFILENAMEWHILEPRINTERON: (0x100B) The profile name was specified while the printer was on.
  • PDERR_NOFONTSRENDER: (0x100C) The printer driver does not support any fonts.

Requirements

Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header CommDlg.h
Library Comdlg32.lib
DLL Comdlg32.dll

See Also

Example

The following example demonstrates how to check for an error after calling GetOpenFileName:


// Assume ofn is an OPENFILENAME structure initialized and passed to GetOpenFileName
if (!GetOpenFileName(&ofn)) {
    DWORD dwError = CommDlgExtendedError();
    if (dwError != 0) {
        // Handle the error appropriately
        // For example, display a message box with the error code
        // MessageBox(NULL, std::to_wstring(dwError).c_str(), L"CommDlgExtendedError", MB_OK);
    }
}