I need help on printing to a printer in microsoft visual c++.
if any of you have any ideas please help
I need help on printing to a printer in microsoft visual c++.
if any of you have any ideas please help
I'm certain this has come by in this forum, Use the search first
or did you already tried?
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.
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
Happy Hunting...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); }
Last edited by kiss_psycho; 02-21-2003 at 05:09 PM.
Definition of Programmer : A red-eyed mumbling mammal capable of conversing with inanimate objects.
Happy Hunting...
The Root
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
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.
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.