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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking the status of local/network printers

Status
Not open for further replies.

Uniquex

Programmer
Dec 16, 2002
15
SG
Hi people.

i use a basic print jobs re-direction software that uses the copy command to copy print jobs across printer queues. so i wish to ask how can i check the status of a port of any local/network printer.

e.g. in the case of the network printer
the network printer was initially shared as 'PrinterA', so the port of the printer when i 'Add printer' in my PC will be sth like '\\PCXXX\PrinterA'

but if someone over at 'PCXXX' accidentally stops sharing or changed the shared name of the shared Printer, the print queue in my PC won't automatically detect the change, and when the software tries to send a file through the old '\\PCXXX\PrinterA' port, disaster starts.

how can i detect and update(if possible) the status and shared name of the shared/local printer in codes...

thanks in advance
 
There are some API functions that may help. WNetEnumResources enumerates connections to printer shares. Could call OpenPrinter/ClosePrinter to check if a shared printer is available. WNetAddConnection2 creates a connection to a network resource. See these kb articles:


I'm not sure if enumerating shared printers on remote machines is possible though if a W2000 domain it probably can be done with ADSI.

Paul Bent
Northwind IT Systems
 
Hi Paul,

thanks for the reply.

i read the articles you shared with me. but i find it too much to consume as i am a newbie at vb6 and had only very little expereince with using APIs

to be specific, what i need to do is to check whether a shared network printer has changed its shared name / whether is it online. (only for one printer)

i think if i enumerate it, i would have to extract it from the large block of data wouldn't i.. that would be way too much unnecesssary coding for what i want to achieve

as for the OpenPrinter/ClosePrinter , it works without relation to the port, as in whether it is a valid one anot.

and also do i need to be on a network to try the samples out? i tested the examples at home but got some erroes

due to my inexperienced, can you please give me more detail help on it?

thank u x 1000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top