Microsoft KB Archive/135119

{|
 * width="100%"|

PRB: StartDoc Fails with Non-Zeroed DOCINFO

 * }

Q135119

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * Microsoft Windows NT Server versions 3.5, 3.51, 4.0
 * Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0
 * Microsoft Windows 95
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Professional

-

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
The following is an example of what the code might display:

 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;

STATUS
This behavior is by design.

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 query words: 3.10 4.00 fail error print DC

Keywords : _IK kbprint kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbSDKWin32 kbOSWin95 kbDSupport kbGDIFAQ

Issue type : kbprb

Technology : kbAudDeveloper kbWin32sSearch kbWin32API