Help and Support
 

powered byLive Search

Sending Output to a Printer

Article ID:23976
Last Review:December 1, 2003
Revision:2.0
This article was previously published under Q23976
On This Page

SUMMARY

This article presents three methods an application can use to send output to a printer.

Back to the top

MORE INFORMATION

Method 1

The first method uses the fprintf() function with the preopened "stdprn" stream. The following code example demonstrates this technique:
   #include <stdio.h>
   main()
   {
      fprintf(stdprn, "a line of text\n");
   }
				
This method works only in the MS-DOS operating system because the "stdprn" stream is not defined by Microsoft Windows or Microsoft Windows NT.

Back to the top

Method 2

Another method uses the fopen() function to open the LPT1, LPT2, or PRN device as a file and uses the fprintf() function to write data to the file handle returned by fopen(). The following code example demonstrates this technique:

   #include <stdio.h>
   main()
   {
      FILE *stream;

      stream = fopen("PRN", "w");
      fprintf(stream, "a line of text\n");
   }
				
This method works in Windows NT as well as the MS-DOS and Windows operating systems.

Back to the top

Method 3

Finally, in MS-DOS, an application can use the int86() or int86x() functions to call one of the following BIOS printer services provided by Interrupt 17h:
service 0: send byte to the printer.
service 1: initialize the printer.
service 2: get printer status.

Back to the top

REFERENCES

For more information on the int86() and int86x() functions, refer to the Microsoft C "Run-Time Library Reference" manual.

Back to the top


APPLIES TO
Microsoft C Professional Development System 5.1
Microsoft C Professional Development System 6.0
Microsoft C Professional Development System 6.0a
Microsoft C/C++ Professional Development System 7.0
Microsoft Visual C++ 1.5 Professional Edition
Microsoft Visual C++ 1.0 Professional Edition
Microsoft Visual C++ 2.0 Professional Edition
Microsoft Visual C++ 4.0 Standard Edition

Back to the top

Keywords: 
KB23976

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.