Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another approach of printer online
Message
 
À
30/11/2009 16:06:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01436991
Message ID:
01437003
Vues:
70
>Hi.
>I know that I can't check from VisualFoxPro if the printer is ready.
>I was thinking if there is a way to get the printer status
>from Windows as the "Printer and Fax" manager do.
>When you open "Printer and fax" from start menu
>you can see that if a printer is OFF the status shows
>"offline" (if you have set icons view to "Tiles").
>If you turn the printer ON the status shows "Ready".
>Somehow "Printer and fax" manager gets the printer status
>from somewhere.

This should give you the correct 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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform