PRB: StartDoc() Fails with Non-Zeroed DOCINFO

Last reviewed: September 29, 1995
Article ID: Q135119
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1, 3.5, and 3.51
        - Microsoft Windows 95 version 4.0
    

SYMPTOMS

A call to StartDoc() fails, and no other reason for failure can be found.

CAUSE

The DOCINFO structure passed to StartDoc() is not initialized to zeros before use.

RESOLUTION

Perform the following three steps:

  1. Call memset() to initialize the structure to zeros.

  2. Set the cbSize member to the appropriate value.

  3. Set the other relevant structure members' values.

Sample Code

Here is an example of what this code might be:

DOCINFO   di;

// Get the DC, SetAbortProc(), and so on.

memset( &di, 0, sizeof( DOCINFO ) ); di.cbSize = sizeof( DOCINFO ); di.lpszDocName = "MyDoc"; if( StartDoc( hDC, &di ) <= 0 )
   HandleFailure();

MORE INFORMATION

As a general rule, any structure that has a member that indicates the size of the structure should be initialized to all zeros before being used by following the previous steps.


Additional reference words: 3.10 3.50 4.00 fail error print DC
KBCategory: kbprint kbprb kbcode
KBSubcategory: GdiPrn



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.