Bonjour à tous,
pour un projet, j'aimerais savoir s'il existe une méthode pour savoir si l'imprimante est en ligne.
Je vous remercie de l'aide que vous allez m'apporter.
[Résolu] Comment savoir si l'imprimante est allumée
[Résolu] Comment savoir si l'imprimante est allumée
Dernière modification par Micoute le jeu. 28/juin/2018 14:20, modifié 2 fois.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Un homme doit être poli, mais il doit aussi être libre !
Re: Comment savaoir si l'imprimante est allumée
Quel modèle d'imprimante ?
À l'époque du DOS, une astuce simple consistait à envoyer CTRL+P vers imprimanteControl + P étant la commande d'éjection de page, l'imprimante se contentait d'éjecter une page blanche. Pour les imprimantes en continu, elle avançait d'une page aussi
Maintenant avec les imprimantes, réseau, USB, WiFi, NFC etc c'est plus compliqué.
Avec une imprimante réseau IP, c'est facile, il suffit de lui faire un ping ou d'accéder par http à son interface de gestion.
Sinon, il faut lui causer par commandes SNMP si elle en dispose et que le dialogue est activé.
Enfin, en utilisant les api on doit pouvoir savoir si une imprimantes est présente, et si elle est en ou hors connexion.
À l'époque du DOS, une astuce simple consistait à envoyer CTRL+P vers imprimante
Code : Tout sélectionner
C:>^P > prn
Maintenant avec les imprimantes, réseau, USB, WiFi, NFC etc c'est plus compliqué.
Avec une imprimante réseau IP, c'est facile, il suffit de lui faire un ping ou d'accéder par http à son interface de gestion.
Sinon, il faut lui causer par commandes SNMP si elle en dispose et que le dialogue est activé.
Enfin, en utilisant les api on doit pouvoir savoir si une imprimantes est présente, et si elle est en ou hors connexion.
-
- Messages : 57
- Inscription : mer. 09/juin/2010 23:47
Re: Comment savaoir si l'imprimante est allumée
Si c'est sous Windows, en passant par l'API.
A voir si ça fonctionne:
A voir si ça fonctionne:
Code : Tout sélectionner
Prototype.l pGetPrinter(hPrinter.l, Level.l, buffer.l, pbSizel, pbSizeNeeded.l)
Prototype.l pOpenPrinter(pPrinterName.s, phPrinter.l, *pDefault.PRINTER_DEFAULTS)
Prototype.l pClosePrinter(hPrinter.l)
Define.pGetPrinter GetPrinter
Define.pOpenPrinter OpenPrinter
Define.pClosePrinter ClosePrinter
Define.l dwBufsize = 0
Define.PRINTER_INFO_2 pinfo
Define.s printerName, msg
OpenLibrary(0, "winspool.drv")
GetPrinter = GetFunction(0, "GetPrinterW")
OpenPrinter = GetFunction(0, "OpenPrinterW")
ClosePrinter = GetFunction(0, "ClosePrinter")
printerName = "Microsoft Print to PDF"
;printerName = "HPOfficejet (HP Officejet Pro 8600)"
If OpenPrinter(printerName, @hPrinter, #Null)
dwBufsize = 0
GetPrinter(hPrinter, 2, #NUL, dwBufsize, @dwBufsize)
*pinfo2.PRINTER_INFO_2 = AllocateMemory(dwBufsize)
GetPrinter(hPrinter, 2, *pinfo2, dwBufsize, @dwBufsize)
Debug "Status : " + *pinfo2\Status
Select *pinfo2\Status
Case 0 : msg = "The printer is ready."; ???
Case #PRINTER_STATUS_BUSY : msg = "The printer is busy."
Case #PRINTER_STATUS_DOOR_OPEN : msg = "The printer door is open."
Case #PRINTER_STATUS_ERROR : msg = "Not used."
Case #PRINTER_STATUS_INITIALIZING : msg = "The printer is initializing."
Case #PRINTER_STATUS_IO_ACTIVE : msg = "The printer is in an active input/output state."
Case #PRINTER_STATUS_MANUAL_FEED : msg = "The printer is in a manual feed state."
Case #PRINTER_STATUS_NO_TONER : msg = "The printer is out of toner."
Case #PRINTER_STATUS_NOT_AVAILABLE : msg = "The printer is not available for printing."
Case #PRINTER_STATUS_OFFLINE : msg = " The printer is offline."
Case #PRINTER_STATUS_OUT_OF_MEMORY : msg = "The printer has run out of memory."
Case #PRINTER_STATUS_OUTPUT_BIN_FULL : msg = "The printer's output bin is full."
Case #PRINTER_STATUS_PAGE_PUNT : msg = "The printer cannot print the current page."
Case #PRINTER_STATUS_PAPER_JAM : msg = "Paper is jammed in the printer."
Case #PRINTER_STATUS_PAPER_OUT : msg = "The printer is out of paper."
Case #PRINTER_STATUS_PAPER_PROBLEM : msg = "The printer has a paper problem."
Case #PRINTER_STATUS_PAUSED : msg = "The printer is paused."
Case #PRINTER_STATUS_PENDING_DELETION : msg = "The printer is pending deletion as a result of a call to the DeletePrinter function."
Case #PRINTER_STATUS_POWER_SAVE : msg = "The printer is in power save mode."
Case #PRINTER_STATUS_PRINTING : msg = "The printer is printing."
Case #PRINTER_STATUS_PROCESSING : msg = "The printer is processing a command from the SetPrinter function."
Case #PRINTER_STATUS_SERVER_UNKNOWN : msg = "The printer status is unknown."
Case #PRINTER_STATUS_TONER_LOW : msg = "The printer is low on toner."
Case #PRINTER_STATUS_USER_INTERVENTION : msg = "The printer has an error that requires the user to do something."
Case #PRINTER_STATUS_WAITING : msg = "The printer is waiting."
Case #PRINTER_STATUS_WARMING_UP : msg = "The printer is warming up."
EndSelect
MessageRequester("", msg, #MB_ICONINFORMATION)
FreeMemory(*pinfo2)
ClosePrinter(hPrinter)
EndIf
CloseLibrary(0)
Re: Comment savaoir si l'imprimante est allumée
Ne serait-ce pas plus simple d'appeler PrintRequester() ?
Ainsi non seulement tu choisis ton imprimante mais tu sais aussi si elle est en ligne.
Ainsi non seulement tu choisis ton imprimante mais tu sais aussi si elle est en ligne.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
[Résolu] Comment savoir si l'imprimante est allumée
Merci à vous tous pour l'entraide qui m'a beaucoup aidé.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Un homme doit être poli, mais il doit aussi être libre !
- falsam
- Messages : 7244
- Inscription : dim. 22/août/2010 15:24
- Localisation : IDF (Yvelines)
- Contact :
Re: [Résolu] Comment savoir si l'imprimante est allumée
Trés bien ce code El Papounet. Merci
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%