A Simple Question

This is a discussion on A Simple Question within the C++ Programming forums, part of the General Programming Boards category; I need help on printing to a printer in microsoft visual c++. if any of you have any ideas please ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Question A Simple Question

    I need help on printing to a printer in microsoft visual c++.
    if any of you have any ideas please help

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    I'm certain this has come by in this forum, Use the search first
    or did you already tried?

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Hmmm....

    I was NEVER able to print from a console application, although I didn't try very hard after realizing that it was an OS related problem. There may be a simple WinAPI function that you can use. (?) Most, but not all, printers will print an ASCII character sent to them. Some printers, such as my current Canon, REQUIRE you to print via the Windows driver. It can't print from a DOS computer.

  4. #4
    Registered User kiss_psycho's Avatar
    Join Date
    Feb 2003
    Posts
    49
    This might Help

    To initialize printer using ROM BIOS service, use interrupt number 23(dec) or 17(Hex). Here service no. 1 initializes the printer, service no. 0 sendes bytes one at a time to the printer.

    Software interrupts can be issued using the int86() function. (valid for 8086 range of processors, all present microprocessors are backward compilant with most 8086 range of instructions and interrupt services.)


    Initialization:
    Input> AH=0x01 //service no
    DX=printer No. (0->LPT1,1->LPT2,etc...)
    Returns status code in AH

    Printing :
    Input > AH=0x00
    AL=the character
    DX=printer No. (0->LPT1,1->LPT2,etc...)
    Returns>AH=Status code
    Bit 0=1 //Time out
    Bit 3=1 //I/O error
    Bit 4=1 //Printer selected
    Bit 5=1 //Out of Paper
    Bit 6=1 //Printer Acknowledge
    Bit 7=1 //Printer not busy

    Code:
    void main()
    {
       struct WORDREGS
       {
          unsigned int ax,bx,cx,dx,si,di,cflag,flags;
       };
       struct BYTEREGS
       {
          unsigned char al,ah,bl,bh,cl,ch,dl,dh;
       };
       union REGS
       {
          struct WORDREGS x;
          struct BYTEREGS h;
       };
    
       union REGS inregs, outregs;
       char c='a';
       
       inregs.h.ah=0x01;
       inregs.x.dx=0;
       int86(0x17,&inregs,&outregs);
    
       inregs.h.ah=0x00;
       inregs.h.al=c;
       inregs.x.dx=0;
       int86(0x17,&inregs,&outregs);
    }
    Happy Hunting...
    Last edited by kiss_psycho; 02-21-2003 at 04:09 PM.
    Definition of Programmer : A red-eyed mumbling mammal capable of conversing with inanimate objects.

    Happy Hunting...
    The Root

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    That old dos stuff wont work in VC++......int86 isnt supported and even if you turn that to inline asm, windows wont allow the interupts to be called in a usermode win32 app....

    Best bet is to look at a few windows tutorials....especially GDI as Winapi treats printers like any device context

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by kiss_psycho
    void main()
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  7. #7
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    kiss_psycho, Look at the link at the top of the board that says "Posting Code? Read This First!" It tells you haw to use code tags.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 08:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 11:15 AM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 05:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21