Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Get Printer Status ByPass Windows Spooler?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01205026
Message ID:
01205167
Vues:
28
I thought this was replied using WMI. WMI gives you the real status of the printer.
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
>Native VFP commands PrintStatus() or Sys(13) didn't work at all, because both pass by Windows Spooler to get printer status. And Windows Spooler does not reflect the real status of the printer. That means the printer is offline or out of paper or completly disconnected and Windows Spooler returns READY. I think it's possible to bypass the Windows Spooler and connect directly to printer port using Winsock with IP Address. I just want an example of code using "MsWinsock.Winsock" to retrieve printer status. Thank you in advance.
>
>P.S.: Please don't submit me any other code using "winspool.drv"... because it's also passing by Windows Spooler and the status returned is wrong.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform