Thread: printer Status always 0

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    2

    Unhappy 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;
    }

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Welcome to the board, use code tags: code /code between []

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    2

    Smile 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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Set Printer Prior To Loading Print Dialog Box
    By Beaner in forum Windows Programming
    Replies: 3
    Last Post: 10-10-2008, 01:02 PM
  2. Getting the printer status
    By leojose in forum Windows Programming
    Replies: 1
    Last Post: 12-12-2005, 09:45 PM
  3. changing property (layout) of a printer
    By leojose in forum Windows Programming
    Replies: 5
    Last Post: 12-05-2005, 07:16 AM
  4. Troubles with Sockets
    By cornholio in forum Windows Programming
    Replies: 6
    Last Post: 10-26-2005, 05:31 AM
  5. Success - Output to Printer
    By noraa in forum C Programming
    Replies: 5
    Last Post: 08-04-2002, 09:12 AM