I have been trying for a month to find out how to detect if a printer is online.
If I can do that, I can use it to load a driver if the printer is online.
I need help converting this to fasm code.
Thanks.
This is what I currently have, but it's not working.
Later I would like to do the same except in Linux.
; Chk_Printer.asm Returns same value in EAX no matter if printer is ON or OFF ??
;
include \masm32\include\masm32rt.inc
include \masm32\include\winspool.inc
includelib \masm32\lib\winspool.lib
.data
hPrinter dd 0
cbBuffer dd 0
_hpdc dd 0
.code
start:
invoke GetDefaultPrinter, NULL, ADDR cbBuffer
print str$(eax),13,10
print str$(cbBuffer),13,10
nop
mov ebx, alloc(cbBuffer)
invoke GetDefaultPrinter, ebx, ADDR cbBuffer
print str$(eax),13,10
print ebx,13,10
nop
; If the function succeeds, the return value is nonzero.
invoke OpenPrinter, ebx, ADDR hPrinter, NULL
print str$(eax),13,10
print hex$(hPrinter),13,10
invoke StartPage, _hpdc
;.if EAX == ERROR_INVALID_HANDLE
;fn MessageBox,0,LastError$(),"Last Error Text",MB_OK
;.else
;.endif
nop
invoke ClosePrinter, hPrinter
print str$(eax),13,10
free ebx
inkey "Press any key to exit..."
exit
end start