🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.visual.3rdparty
Article #20

Re: VB5 Check if Printer is Online

#20
From: liebi
Date: Tue, 29 Jun 1999 00:00
81 lines
4910 bytes
Giles, JC,

Have been fighting the same problem for the last couple of days ...

There are possibilities to get information from the printer regarding its
condition:
Use OpenPrinter to establish a printer handle, then query the printer with
GetPrinter. This will fill a PRINTER_INFO_2 structure, which contains (among
other stuff) information about the printer status (f.ex. Offline, Error, etc
...)
This is not so easy to do from VB (at least if you, as me, have very little API
programming background) ... if you have access to the MSDN (which is one
prerequesite to make this work), find the article "FIX: Setting Printer to Item
in the Printer Collection Fails", in which they give an example how to retrieve
a PRINTER_INFO_5 structure using GetPrinter ... the important thing is how they
were able to read the data into a buffer (you probably would prefer to read
PRINTER_INFO_2, which contains more relevant info then PRINTER_INFO_5) not the
program as a whole ...

Hope this makes sense.

Philipp


Giles Thurston wrote:

> Cheers for the response JC.  At least I now know that its not just me being
> stupid.
>
> I spend many a brain draining hour trawling through API books etc.  I called
> MS and the solutions they gave me didn't work.
>
> Eventually after playing around with MS solutions I was able to get a
> workable solution.
>
> I used the enumJobs API call to monitor the status of the first job in the
> Printer Queue.  When the dialog box is displayed by Windows saying "There is
> a problem with you printer etc" the status of the Job changes to a new
> value.  By detecting this change I was able to remove Printing Job from the
> Printer Queue using another API (SetJob I think!).
>
> This allows you to detect the majority of problems with a printer with the
> exception of one.  If a printer is physically turned off Windows (95
> anyway!) doesn't seem to care!  Windows appears to place a job in the
> Printer Queue and then delete it immediately with no change in state and no
> error reported.  Even if you print a document from Word to a Printer which
> is off you get the same Error.  The response from MS on this was ".. well if
> Word doesn't catch it you probably won't be able to.."
>
> Anyway that in a nutshell is my solution. Feel free to contact me for
> further details.
>
> Any better solutions would be gratefully received
>
> regards
>
> GilesT@mentor.co.uk
>
> JC wrote in message <370D67DE.E3905845@home.com>...
> >I missed the first part of this thread, but I have been trying to get to
> >the printer ports (parallel) myself for some time, and they are getting
> >harder and harder to get to.
> >
> >I work with a multi-user Point of Sale system, and we need to be able to
> >detect problems with printers automatically and re-route the printout to
> >another printer when there is a problem.  I managed to do this by
> >building my own spooler for serial printers, but with the print manager
> >taking over things, I cannot get to the parallel printers.  Printing a
> >line at a time to LPT1 is not even supported in NT anymore, so that's
> >out.
> >
> >Yeah, I spent a few days with those API's, but never found one that
> >could tell (from VB, mind you) that the printer jammed, or went off-line
> >in the middle of a printout, then let me handle things by re-routing to
> >the next printer on my user's pre-defined list.  Some crusty old
> >seasoned programmers have told me that it is impossible.
> >
> >I have no words of wisdom, but you do have my sympathy - and please do
> >let me (or the group) know if you find something handy....
> >
> >JC
Technical Details
Message-ID: <3778C692.A0F41DBD@gulasch.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7e073e$t3e$1@uranium.btinternet.com> <8D9C9305Fckincaidatkcdotnet@msnews.microsoft.com> <7ecej0$eeu$1@plutonium.btinternet.com> <370D67DE.E3905845@home.com> <7elc38$k4n$1@mendelevium.btinternet.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5f6f,c60f5e217257965a
X-Google-Attributes: gidf5f6f,public
X-Google-Thread: fb992,c60f5e217257965a
X-Google-Attributes: gidfb992,public
X-Google-Thread: 110e3b,c60f5e217257965a
X-Google-Attributes: gid110e3b,public
X-Google-Thread: 108062,c60f5e217257965a
X-Google-Attributes: gid108062,public
X-Google-Thread: 1143a7,c60f5e217257965a
X-Google-Attributes: gid1143a7,public
X-Google-Thread: 100d42,c60f5e217257965a
X-Google-Attributes: gid100d42,public
From: liebi <liebi@gulasch.de>
Subject: Re: VB5 Check if Printer is Online
Date: 1999/06/29
Message-ID: <3778C692.A0F41DBD@gulasch.de>
X-Deja-AN: 495179557
Content-Transfer-Encoding: 7bit
References: <7e073e$t3e$1@uranium.btinternet.com> <8D9C9305Fckincaidatkcdotnet@msnews.microsoft.com> <7ecej0$eeu$1@plutonium.btinternet.com> <370D67DE.E3905845@home.com> <7elc38$k4n$1@mendelevium.btinternet.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Premium Gulasch
MIME-Version: 1.0
Newsgroups: comp.lang.basic.visual.3rdparty,comp.lang.basic.visual.database,comp.lang.basic.visual.misc,comp.lang.visual.basic,cz.comp.lang.basic.visual,microsoft.public.basic.other