greendot
asked on
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
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
Perhaps enumerating the network resources with WNetOpenEnum helps?
Regards, Madshi.
Regards, Madshi.
If you use TCP/IP to network print (like LPR), you can try to ping the printer first. No ping - no printer.
ASKER
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
I'm going to try that WNetOpenEnum thing and see if it works.
-j
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
thanks.
-gd
ASKER
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
I'm going to see if that one passes tests on all Win32 platforms.
-gd
Please keep us informed about the results of your tests - thank you!! :-)
ASKER
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...
But, I move to a friends machine and it doesn't work.
The enumeration code example still works...
Okay, thanx for the info...
:-)
:-)
Does the exception only occur when you output ???
Regards