C Run-time _stdprn and _stdaux Not Available under Win32
  
PSS ID Number: Q130484
Article last modified on 10-12-1995
 
1.00 2.00 2.10
 
WINDOWS NT
 

-----------------------------------------------------------------------
The information in this article applies to:
 
 - The C Run-time (CRT) included with:
   Microsoft Visual C++, 32-bit Edition, versions 1.00, 2.00, and 2.10
   on the following platforms: x86, MIPS, Alpha, Power PC
-----------------------------------------------------------------------
 
SUMMARY
=======
 
The 16-bit C run-time MS-DOS library provides a standard I/O package for
the following five file handles: stdin, stdout, stderr, _stdprn, and
_stdaux. Under the 16-bit C run-time, stdprn and stdaux default to the
first printer port and the first serial port respectively (if any exist).
Under Win32, there are no automatic file handles to the first printer and
first serial port, so only stdin, stdout, and stderr are made available by
the C Run-time library.
 
If you want to simulate the same behavior under Win32, you need to
open the devices explicitly, in BINARY mode, using fopen. The device
names you need to use are as follows:
 
 - PRN (first available printer port), LPT1, LPT2, LPT3, LPT4
 - AUX (first available serial port), COM1, COM2, COM3, COM4
 
MORE INFORMATION
================
 
The following is a code fragment that illustrates how to use each
type of device:
 
Code Sample
-----------
 
#include <stdio.h>
 
FILE * stdprn, * stdaux;
 
void main(void)
{
   FILE *prn2, *com2;
 
   // open PRN in BINARY mode and send a test string
 
   if ((stdprn = fopen("PRN","wb")) != NULL)
   {
      fprintf(stdprn, "Prints to the printer \n\r");
   }
 
   // open LPT2 in BINARY mode and send a test string
 
   if ((prn2 = fopen("LPT2","wb")) != NULL)
   {
      fprintf(prn2, "Prints 1 line to LPT2 \n\r");
   }
 
   // open AUX in BINARY mode and send a test string
 
   if ((stdaux = fopen("AUX","wb+")) != NULL)
   {
      fprintf(stdaux, "ATZ\r"); // Send reset command to AUX
   }
 
   // open COM2 in BINARY mode and send a test string
 
   if ((com2 = fopen("COM2","wb+")) != NULL)
   {
      fprintf(com2, "ATH\r");   // Send modem command to COM2
   }
}
 
REFERENCES
==========
 
For more information about other issues concerning the usage of the stdprn
device, please see the following article in the Microsoft Knowledge Base:
 
ARTICLE-ID:Q68944
TITLE     :Output to stdprn Is in Binary (Untranslated) Mode
 
Additional reference words: kbinf 1.00 2.00 2.10
KBCategory: kbprg kbcode
KBSubcategory: CRTIss
=============================================================================
Copyright Microsoft Corporation 1995.
