-
printer Status always 0
This code gets the printer name right, but no matter if I pull the trays out, it still reports printer status 0. "Meaning ready"
I want to run my program on automatic, to print reports all night
When I am not there, but If it is out of paper, I wish to stop printing, I want to know what has been really printed.
long GetPrinterStatus (void)
{
unsigned long dwNeeded, dwReturned;
// HDC hdc ;
PRINTER_INFO_2 * pinfo2 ;
// PRINTER_INFO_6 * pinfo6 ;
long x;
if (GetVersion () & 0x80000000 || GetVersion () == 0xC0005A04 ) // Windows 98 || ME
{
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 2, NULL,0, &dwNeeded, &dwReturned) ;
OpenPrinter( pinfo5->pPrinterName, &hdc, 0 );
GetPrinter( hdc,2,0, 0, &dwNeeded );
pinfo2 = ( PRINTER_INFO_2 * ) malloc (dwNeeded) ;
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 2, (PBYTE) pinfo2, dwNeeded, &dwNeeded, &dwReturned) ;
GetPrinter( hdc,2,(LPBYTE) pinfo2, dwNeeded, &dwNeeded );
x = pinfo2->Status;
}
else // Windows NT
{
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &dwNeeded, &dwReturned) ;
OpenPrinter( pinfo4->pPrinterName, &hdc, 0 );
GetPrinter( hdc,2,0, 0, &dwNeeded );
pinfo2 = ( PRINTER_INFO_2 * ) malloc (dwNeeded) ;
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 2, (PBYTE) pinfo2, dwNeeded, &dwNeeded, &dwReturned) ;
GetPrinter( hdc,2,(LPBYTE) pinfo2, dwNeeded, &dwNeeded );
x = pinfo2->Status;
}
return x;
}
-
Welcome to the board, use code tags: code /code between []
-
status 223?
This seems to work both ways on ME.
I do not know why 223 seems to be the base line.
I am going to try it on 2000 tomorrow.
code :
#include <bios.h>
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define statuslpt1 0x379
int main(void)
{
int x;
#ifdef __BORLANDC__
unsigned char c;
c = inportb( statuslpt1 );
#endif
#ifdef __WATCOM__
int c;
c = inp( statuslpt1 );
#endif
printf ( "\n %d",( int )c );
getch();
asm
{
mov ah, 2
mov dx, 0
int 17h
mov al,ah
mov c,ax
}
if ( c == 223 )
{
x = 1;
printf ( "\n ok" );
}
else
{
x=0;
printf ( "\n error" );
}
getch();
return x;
}
/code