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

test status of a printer shared on the network

Status
Not open for further replies.

HanzieV

Programmer
Apr 8, 2003
17
0
0
BE
Hi all,

is there an easy way to check the status of a printer that is shared on another pc in VFP 7.0 ??

Best regards,
Hans
 
Try this. This requires WMI to be installed

Code:
strComputer = "."
strComputer = "."
objWMIService = Getobject("winmgmts:"+ "{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2")
colInstalledPrinters = objWMIService.ExecQuery("SELECT * FROM Win32_Printer")
For Each objPrinter In colInstalledPrinters
?"Name: " + objPrinter.Name
Do Case
Case objPrinter.PrinterStatus = 1
strPrinterStatus = "Other"
Case objPrinter.PrinterStatus = 2
strPrinterStatus = "Unknown"
Case objPrinter.PrinterStatus = 3
strPrinterStatus = "Idle"
Case objPrinter.PrinterStatus = 4
strPrinterStatus = "Printing"
Case objPrinter.PrinterStatus = 5
strPrinterStatus = "Warmup"
Endcase
? "Printer Status: " + strPrinterStatus
Next


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Hi Mike,

thank for your answer. Could you tell me where I can find 'WMI' and how I have to install it ??

Best regards,
Hans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top