PRB: StartDoc() Fails Because the File Name Is Too Long (281128)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows XP
  • the operating system: Microsoft Windows XP 64-Bit Edition

This article was previously published under Q281128

SYMPTOMS

The function StartDoc fails and the function GetLastError returns ERROR_FILENAME_EXCED_RANGE. This error is returned when the document name string that is passed to the StartDoc function is too long.

CAUSE

When applications print they typically call the StartDoc function to indicate the start of the print job. This function takes a parameter of the structure type DOCINFO that has structure members to describe the print job.

The members of the DOCINFO structure can be the cause of a StartDoc function call failure if they are improperly initialized. This article describes the case in which the StartDoc function fails and the error returned by the GetLastError function is "ERROR_FILENAME_EXCED_RANGE" (decimal value 206).

This error value is returned because the operating system has found a string member of the DOCINFO structure to be too long. The StartDoc function validates its parameters by checking that the length of the lpszDocName and the lpszOutput members of the DOCINFO structure are less than MAX_PATH.

RESOLUTION

To avoid the failure of the StartDoc function call in this case, ensure that all strings assigned to the DOCINFO structure have character counts (string lengths) that are less than MAX_PATH. MAX_PATH is currently defined in the Platform SDK header file Windef.h.

Modification Type:MinorLast Reviewed:4/3/2006
Keywords:kbDSWGDI2003Swept kbGDI kbpending kbprb kbprint kbSpooler KB281128