Detecting if network printer has been removed

Is there a way to detect if a network printer has been removed?

What's happening in our app is that various client machines all point to a central network printer.  When that printer is removed, all clients still point to it... and when we try to print to that printer, we get exceptions generated.

Dealing with the exceptions isn't a problem, but we would like to figure out a way to detect the situation before we start to print.  (There is a lot of overhead in page generation before the exceptions are raised.)

Any clues?

thanks
greendot
LVL 2
greendotAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MadshiConnect With a Mentor Commented:
I've seen this link from another expert here (Alex/simonet):

http://www.bhnet.com.br/~simonet/extras/wnet_srvr.zip
0
 
KECommented:
Why not branch on an exception in the first stage - before generating the page ?

Does the exception only occur when you output ???

Regards
0
 
MadshiCommented:
Perhaps enumerating the network resources with WNetOpenEnum helps?

Regards, Madshi.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sburckCommented:
If you use TCP/IP to network print (like LPR), you can try to ping the printer first.  No ping - no printer.
0
 
greendotAuthor Commented:
In house, we use TCP/IP, but the customer base is supposed to be able to use any windows based networking - i.e. invisible to us.

I'm going to try that WNetOpenEnum thing and see if it works.

-j
0
 
greendotAuthor Commented:
Madshi, that code example you pointed me to worked perfectly.  All I had to do was remove the good parts and turn it into a function that dealt with only printer resources.

thanks.

-gd
0
 
greendotAuthor Commented:
FYI, it turns out that a simple call to OpenPrinter (winspool.pas) will return false in the case that the printer is no longer attached to the server.

I'm going to see if that one passes tests on all Win32 platforms.

-gd
0
 
MadshiCommented:
Please keep us informed about the results of your tests - thank you!!   :-)
0
 
greendotAuthor Commented:
Well, OpenPrinter works perfectly on my development machine.  It fails and passes on the correct printers.  

But, I move to a friends machine and it doesn't work.

The enumeration code example still works...
0
 
MadshiCommented:
Okay, thanx for the info...  
:-)
0
All Courses

From novice to tech pro — start learning today.