none
Printer online RRS feed

  • Question

  • I have tried for a month to find source code that will determine if a printer is online and available for printing.

    Ring 3 Windows Printer API's can not determine that information.

    It looks like a printer driver is the only way to determine that.

    Does someone have some source code to get me started ?

    I have the WDK installed and currently program in Win32 assembly.

    From what I have read, I may have to query the virtual U.S.B. port that is used in printing.

    Thanks.

    Monday, April 1, 2013 3:04 PM

All replies

  • If you're doing Win32 programming, PRINTER_INFO_2->Status field shows the status of a printer. You definitely don't need to have a print driver to determine this. http://msdn.microsoft.com/en-us/library/windows/desktop/dd162845(v=vs.85).aspx

    If you're programming a Windows Store app, you can enumerate the devices using the Windows.Devices namespace, and check their status, but you cannot initiate printing directly (so I wouldn't recommend going out of your way to check the status ahead of time). Instead, the user must choose a device in Windows Store app printing.

    • Marked as answer by Doron Holan [MSFT] Tuesday, April 2, 2013 7:54 PM
    • Unmarked as answer by Andy77586 Tuesday, April 2, 2013 11:41 PM
    Tuesday, April 2, 2013 5:08 PM
  • I could not get Printer_Info_2 to work, but 6 provides a printer status as well.

    Eax returns 5 whether printer is online or not.

    Andy

    PRINTER_INFO_6 STRUCT dwStatus DWORD ? PRINTER_INFO_6 ENDS ;============================================================================== .data hPrinter dd 0 cbNeeded dd 0 cch dd 100 pd PRINTER_DEFAULTS <0,0,PRINTER_ALL_ACCESS> buffer db 100 dup(0) .code ;============================================================================== start: ;============================================================================== invoke GetDefaultPrinter, ADDR buffer, ADDR cch printf("%d\t%s\n", eax, ADDR buffer) invoke OpenPrinter, ADDR buffer, ADDR hPrinter, ADDR pd printf("%d\t%Xh\n", eax, hPrinter) invoke GetPrinter, hPrinter, 6, 0, 0, ADDR cbNeeded printf("%d\t%d\n", eax, cbNeeded) mov ebx, alloc(cbNeeded) invoke GetPrinter, hPrinter, 6, ebx, cbNeeded, ADDR cbNeeded printf("%d\t%d\n", eax, [ebx].PRINTER_INFO_6.dwStatus) int 3 inkey exit


    Tuesday, April 2, 2013 9:08 PM
  • How about you test this in C to make sure what you are observing about the status is truly correct or not and not a mistake in your asm translation of the struct and calls. There is absolutely no reason to implement this in asm

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, April 3, 2013 2:49 AM
  • Is there no one else that is willing to help me  ?

    Microsoft writes Operating Systems, this shouldn't be that hard.

    I would appreciate any help and acknowledge it.

    Andy

    Friday, April 5, 2013 10:04 PM