flat assembler
Message board for the users of flat assembler.

Index > Windows > Determine if printer is online

Author
Thread Post new topic Reply to topic
Fixit



Joined: 22 Nov 2012
Posts: 161
Fixit 22 Mar 2013, 14:47
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.

Code:
; 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 
    
Post 22 Mar 2013, 14:47
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 22 Mar 2013, 18:04
Try to code this in C first and verify that it works. Then convert your API calls to FASM. This will isolate the problems (that is, if it is a problem with your ASM, then your C version should not suffer from it).
Post 22 Mar 2013, 18:04
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.