Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check/know when a network printer is offline?

Status
Not open for further replies.

Vodka32

Programmer
Oct 15, 2003
4
PH
Greeting to all,
We are creating a form to print in multiple printers in our network, we were able to print on them, what we want now is to have a messagebox telling the user that the printer is turned off so that the print job wont be spooled in other printers...

This is our setup, 1 epson lx-300 w/c connect to a local machine is used to print Official Receipts, another epson lx-300 is connected on another machine w/c is shared is used to print class schedules and another hp deskjet 860C is connected on another machicne w/c is also shared is used to print class cards... when we send a print command to the 3 printer it prints well... our problem is when 1 printer is turned off (we're simulating when a printer bugs donw) the printing job for that printer is send to the other printer... can we control that in such a way the user will be informed that the printer is turned off and will cancel the print job?

Thanks,
Ben
 
There is no function in VFP that works. The PrintStatus function always returns .T. for network printers. (Forget about what the Help says.)

I haven't tried this myself, but you may want to try a Windows API for this. Something like this:
Code:
DECLARE INTEGER OpenPrinter IN Winspool.drv;
  STRING @pPrinterName,	INTEGER @phPrinter,;
  STRING @pDefault

lcprinter = GETPRINTER()
lnhandle = 0
IF NOT EMPTY(lcprinter)
  IF OpenPrinter(@lcprinter, @lnhandle, 0) # 0
    * The printer was opened
    * Note: Be sure to close the printer
    * when done using ClosePrinter()
  ELSE
    * The call failed call GetLastError() to retrieve
    * the error number
  ENDIF
ENDIF



-BP
 
Ben

Maybe there is another way to work around your problem. Since network printers typically go into que, can you try putting in code to ensure the output is going to that specific printer? Then again, maybe you have already tried this. Here is what I am thinking, but admittedly just brainstorming.

* save current printer
lcDefaultPrinter = SET("PRINTER",3)
lcOutputPrinter = "HP III"
SET PRINTER TO NAME (lcOutputPrinter)
REPORT FORM blah
lcDefaultPrinter = SET("PRINTER",3)


Where I hardcode "HP III" you would place your printer. To get a list of all the printer names look at the APRINTER() function.




Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top