Microsoft KB Archive/907299

= The printed output is sent to a printer's port instead of to the requested output file when you try to print a file programmatically in Windows XP =

Article ID: 907299

Article Last Modified on 11/23/2005

-

APPLIES TO


 * Microsoft Windows XP Home Edition
 * Microsoft Windows XP Professional

-





SYMPTOMS
When you try to print a file programmatically in Microsoft Windows XP, the printed output is sent to a printer's port instead of to the requested output file. This problem occurs when all the following conditions are true:
 * You configure the printer to spool documents.
 * You use the DOCINFO.lpszOutput structure member to specify an output file for the print job.
 * The file that you specify in the DOCINFO.lpszOutput structure member is locked by another process or thread.



WORKAROUND
To work around this problem, follow these steps:  Make sure that the file that you have specified is not locked by any other process or thread. Configure the printer to print directly to a port instead of to spool documents. Apply the hotfix that is discussed in the following Microsoft Knowledge Base (KB) article:

905519 You experience problems when you try to print to a file programmatically in Windows XP





Steps to reproduce the problem
 Add a local printer that uses a new local port. For example, set the local port to a file path such as the following:



 In the printer Properties dialog box, click Advanced, click Spool print documents so program finishes printing faster, and then click OK.</li> Determine a file name for a second file that you want to receive the print job. For example, you may assign a file name for the DOCINFO.lpszOutput structure member as follows:

DOCINFO.lpszOutput = :\ \

Note A value for the DOCINFO.lpszOutput structure member is specified if you want to print to a file.</li> Use a separate thread or process to open the Test2_output.prn file and to hold the file open.</li> While the test2_output.prn file is open, try to print to the file by using the DOCINFO.lpszOutput structure member and the StartDoc function on the first thread or process.</li></ol>

The print job output is sent to the port that you set up in step 1 instead of to the file that you specified in the DOCINFO.lpszOutput structure member.

Keywords: kbtshoot kbprb KB907299

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.