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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
sburckCommented:
If you use TCP/IP to network print (like LPR), you can try to ping the printer first.  No ping - no printer.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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
MadshiCommented:
I've seen this link from another expert here (Alex/simonet):

http://www.bhnet.com.br/~simonet/extras/wnet_srvr.zip
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.