How to Do a Print Screen Within a Program

Last reviewed: July 17, 1997
Article ID: Q59380
5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS                      | WINDOWS
kbprg

The information in this article applies to:

  • The C Run-time (CRT) included with:

        - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SUMMARY

The code below demonstrates how to do a print screen from within a program under MS-DOS. This is done by executing Interrupt 5 within a program.

MORE INFORMATION

The interrupt service directs all its output to the default printer. The print-screen service prints text or graphics. In graphics mode, GRAPHICS.COM must be loaded before invoking the print-screen service.

Interrupt 5 does not return any values but the status code is available at memory location 0050:0000. The values are as follows:

   00   No error occurred
   01   Indicates that a print-screen operation is in progress
   FF   The previous print screen was not successful.

Sample Code

  #include <stdio.h>
  #include <dos.h>

  void main (void)
  {
     int  *result;
     union REGS inregs, outregs;

  /* inregs and outregs are never used but necessary
     for the int86 function.
  */

     puts("This is a test of prtscr() function.");
     int86(0x5, &inregs, &outregs);

     result = (int *) 0x00500000;
     switch( *result )
     {
        case 0:
          puts("No error occurred.");
          break;
        case 1:
          puts("Print Screen in progress....");
          break;
        case 0xFF:
          puts("ERROR occurred during print screen");
          break;
     }
  }


Additional reference words: kbinf 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50
KBCategory: kbprg
KBSubcategory: CRTIss
Keywords : kb16bitonly


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: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.