|
| Résultats de la recherche |
| Votre recherche pour le terme 'etat imprimante openprinterA' a retourné 9 résultats |
|
| Astuce : pour rechercher vos message publiés, précédez votre recherche par le mot-clé "moi:" |
| | |
|
| |
| Posté le 20 février 2017 - 12:55 par Philippe Pasquali dans |
Bonjour je viens de sortir du carton ma vieille imprimante pour tester ce très vieux bout de code et voici les corrections apportées :
FUNCTIONiPrinterGetStatus(pPrinterName=iInfoImprimante()) hdPrint,RetAPI,cbBuf,pcbNeededsont desentiers sPrinterNameest une chaîne ASCIIZ sur512=pPrinterName tPRINTERest un_PRINTER_INFO_2 PRINTER_INFO_LEVELest un entier=2 BufferAPIest unBuffer
RetAPI=API(winspool_drv,"OpenPrinterA", &sPrinterName, &hdPrint,Null) IFRetAPI=0THEN RENVOYER""
cbBuf=0 pcbNeeded=0
RetAPI=API(winspool_drv,"GetPrinterA",hdPrint,PRINTER_INFO_LEVEL, &tPRINTER,cbBuf, &pcbNeeded)
cbBuf=pcbNeeded BufferAPI=Répète(Caract(0x00),cbBuf)
RetAPI=API(winspool_drv,"GetPrinterA",hdPrint,PRINTER_INFO_LEVEL, &BufferAPI,cbBuf, &pcbNeeded) IFRetAPI=0THEN API(winspool_drv,"ClosePrinter",hdPrint) RENVOYER"" END
API(winspool_drv,"ClosePrinter",hdPrint)
Transfert(&tPRINTER, &BufferAPI,Dimension(tPRINTER))
ServeurNameest une chaîne=ChaîneRécupère(tPRINTER:pServerName,crAdresseASCIIZ) PrinterNameest une chaîne=ChaîneRécupère(tPRINTER:pPrinterName,crAdresseASCIIZ) ShareNameest une chaîne=ChaîneRécupère(tPRINTER:pShareName,crAdresseASCIIZ) PortNameest une chaîne=ChaîneRécupère(tPRINTER:pPortName,crAdresseASCIIZ) DriverNameest une chaîne=ChaîneRécupère(tPRINTER:pDriverName,crAdresseASCIIZ) Commentest une chaîne=ChaîneRécupère(tPRINTER:pComment,crAdresseASCIIZ) Locationest une chaîne=ChaîneRécupère(tPRINTER:pLocation,crAdresseASCIIZ) DevModeest une chaîne=ChaîneRécupère(tPRINTER:pDevMode,crAdresseASCIIZ) SepFileest une chaîne=ChaîneRécupère(tPRINTER:pSepFile,crAdresseASCIIZ) PrintProcessorest une chaîne=ChaîneRécupère(tPRINTER:pPrintProcessor,crAdresseASCIIZ) sDatatypeest une chaîne=ChaîneRécupère(tPRINTER:pDatatype,crAdresseASCIIZ) Parametresest une chaîne="" Attributest un entier système=tPRINTER:Attributes Priorityest un entier système=tPRINTER:Priority DefaultPriorityest un entier système=tPRINTER:DefaultPriority StartTimeest un entier système=tPRINTER:StartTime UntilTimeest un entier système=tPRINTER:UntilTime Statusest un entier système=tPRINTER:Status cJobsest un entier système=tPRINTER:cJobs AveragePPMest un entier système=tPRINTER:AveragePPM
Resultatest une chaîne="" Resultat+=ServeurName+TAB Resultat+=PrinterName+TAB Resultat+=ShareName+TAB Resultat+=PortName+TAB Resultat+=DriverName+TAB Resultat+=Comment+TAB Resultat+=Location+TAB Resultat+=DevMode+TAB Resultat+=SepFile+TAB Resultat+=PrintProcessor+TAB Resultat+=sDatatype+TAB Resultat+=Parametres+TAB Resultat+=NumériqueVersChaîne(Attribut) +TAB Resultat+=NumériqueVersChaîne(Priority) +TAB Resultat+=NumériqueVersChaîne(DefaultPriority) +TAB Resultat+=NumériqueVersChaîne(StartTime) +TAB Resultat+=NumériqueVersChaîne(UntilTime) +TAB Resultat+=NumériqueVersChaîne(Status) +TAB Resultat+=NumériqueVersChaîne(cJobs) +TAB Resultat+=NumériqueVersChaîne(AveragePPM) +TAB
RENVOYERResultat testé avec Win7-Windev20-Printer USB Je pense que le status représente plus le status du spooler que de l'imprimante physique. Si l'imprimante est éteinte, que le spooler soit vide ou pas on obtient 0.
prête avec papier et toner => 0 en pause => 1 >plus de papier => 16 |
| | | |
|
| | |
| |
| Posté le 30 août 2006 - 22:23 par philippe.pasquali dans |
D'aprés ce que j'ai compris la fonction rempli une zone mémoire avec les valeurs pour 1 seule tSTATUS (taille fixe) puis par avec une zone de type buffer binaire (taille variable) En windev on ne peut pas déclarer ce type de donnée qui est un peut batarde à mon goût
Exemple _point est une structure x est un entier y est un entier end
si tu fais : point est un point
tu auras en mémoire 1 octet de x 2 octet de x 3 octet de x 4 octet de x // car un entier avec Windev est sur 4 octets 5 octet de y 6 octet de y 7 octet de y 8 octet de y // car un entier avec Windev est sur 4 octets
Si tu fais : tblpoint est un tableau de 100 point tu auras en memoire 100 fois de suite le shémas de dessus 100*8 octets
Mais rien ne t'empêche ( et µ$soft ne se géne pas) d'y mette autre chose car ce n'est que des octets ! les deux * 4 premiers octets étant des adresses de zone mémoire pointant dans les (100-2)*8 octets suivants qui eut ne sont absolument pas structuré comme des tSTATUS. Voila l'explication du tSTATUS[1] car c'est le seul d'utile
Si tu veux voir exactement comment cela se passe tu fais phPrinter est un entier RetCode est un entier BufferBin est une chaîne fixe sur 5000 pcbNeeded est un entier IF API( "winspool.drv" ,"OpenPrinterA", "\\BROSRV002\BROPRT219", &phPrinter, Null) <> 0 ALORS RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, Null, 0,&pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &BufferBin, pcbNeeded, &pcbNeeded) STOP // ICI AVEC LE DEBOGUEUR, inspecter la variable : Remplace(BufferBin[[1 sur pcbNeeded]], Caract(0x0),".") // et tu vas entre guillemet comprendre.... le début du buffer est organisé celon la structure tSTATUS qui contient // des adresse sur des zones contenus aprés la structure. API("winspool.drv", "ClosePrinter", phPrinter) END
"Graviere Julien" <gravierejulien@yahoo.fr> a écrit dans le message de news: 44f3e771$1@news.pcsoft.fr...
Ce message à l'attention de Philippe Pasquali ou tout autre developpeur ayant eu besoin du code ci-après :
Suite au code posté sur le Forum le 15/06/2005, je tente d'obtenir le statut de mon imprimante et cela ne fonctionne pas : même quand l'imprimante est en erreur, le code me renvoie 0 (tout est ok). Je ne comprends pas cette ligne : Etat = tSTATUS[1]:status //Pourquoi un indice de 1? //Pourquoi ce n'est pas dynamique //Puis je avoir plus d'explication?
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END ----------------------------------------------------------------------------------------------- pPrinterName est une chaîne ASCIIZ sur 256 = pPrinter phPrinter est un entier = 0 pcbNeeded est un entier = 0 RetCode est un entier tSTATUS est un tableau dynamique de 100 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 2048 Etat est un entier = 0 Req est une chaîne InfoErreur est une chaîne ------------------------------------------------------------------------------------------- SI API( "winspool.drv" ,"OpenPrinterA", pPrinterName, &phPrinter, Null) <> 0 ALORS RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, 0,&pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS,pcbNeeded, &pcbNeeded) SI RetCode<>0 ALORS Etat = tSTATUS[1]:status FIN API("winspool.drv", "ClosePrinter", phPrinter) FIN >
|
| | | |
|
| | |
| |
| Posté le 29 août 2006 - 14:05 par philippe.pasquali dans |
Attention dans ma copie il y a une bourde ........... > RENVOYER Status **************************** LE PROGRAMME FINI ICI ****************************
Status = tPRINTER[1]:Status
API("winspool.drv","ClosePrinter", hdPrint)
RENVOYER Status // peut etre un OuBinaire des constantes
Si je met mon imprimante en pause, j'ai bien PRINTER_STATUS_PAUSED = 0x00000001 mais si le document est en erreur, je pense qu'il faut aller voir le status du job et non du spool
"philippe pasquali" <philippe.pasquali@bopack.fr> a écrit dans le message de news: 44f3f69b$1@news.pcsoft.fr...
Depuis j'avais modifié le bazard (sans le dire : pas bien çà) j'utilise PRINTER_INFO_6 qui est plus adaptée à ce type de fonction //**************************** CONSTANT // STATUT D'UNE IMPRIMANTE................... // Peut etre une combinaison de ces valeurs PRINTER_STATUS_PAUSED = 0x00000001 PRINTER_STATUS_ERROR = 0x00000002 PRINTER_STATUS_PENDING_DELETION = 0x00000004 PRINTER_STATUS_PAPER_JAM = 0x00000008 PRINTER_STATUS_PAPER_OUT = 0x00000010 PRINTER_STATUS_MANUAL_FEED = 0x00000020 PRINTER_STATUS_PAPER_PROBLEM = 0x00000040 PRINTER_STATUS_OFFLINE = 0x00000080 PRINTER_STATUS_IO_ACTIVE = 0x00000100 PRINTER_STATUS_BUSY = 0x00000200 PRINTER_STATUS_PRINTING = 0x00000400 PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800 PRINTER_STATUS_NOT_AVAILABLE = 0x00001000 PRINTER_STATUS_WAITING = 0x00002000 PRINTER_STATUS_PROCESSING = 0x00004000 PRINTER_STATUS_INITIALIZING = 0x00008000 PRINTER_STATUS_WARMING_UP = 0x00010000 PRINTER_STATUS_TONER_LOW = 0x00020000 PRINTER_STATUS_NO_TONER = 0x00040000 PRINTER_STATUS_PAGE_PUNT = 0x00080000 PRINTER_STATUS_USER_INTERVENTION = 0x00100000 PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000 PRINTER_STATUS_DOOR_OPEN = 0x00400000 PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000 PRINTER_STATUS_POWER_SAVE = 0x01000000 INVALID_PRINTER = 0x10000000 END //**************************** _PRINTER_INFO_6 est une structure Status est un entier END //**************************** // Renvoie le status d'une imprimante//**************************** FUNCTION iGetStatus(pPrinterName=iInfoImprimante()) Status, hdPrint, Ret, cbBuf, pcbNeeded sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName tPRINTER est une x_PRINTER_INFO_6 PRINTER_INFO_LEVEL est un entier = 6 Buf est une chaîne ASCIIZ sur 1024 Status = INVALID_PRINTER // Ouverture du handle avec l' imprimanteRet = API( "winspool.drv", " OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER Status // Execution de la fonction une fois avec 0 pour connaitre le nombre exact cbBuf = 0 pcbNeeded = 0 API( "winspool.drv", "GetPrinterA", hdPrint, PRINTER_INFO_LEVEL, &tPRINTER, cbBuf, &pcbNeeded) // Met le nombre renvoyer par le premier appel cbBuf = pcbNeeded Ret = API( "winspool.drv", "GetPrinterA", hdPrint, PRINTER_INFO_LEVEL, &tPRINTER, cbBuf, &pcbNeeded) IF Ret = 0 THEN API("winspool.drv","ClosePrinter", hdPrint) RENVOYER Status END Status = tPRINTER:Status API("winspool.drv","ClosePrinter", hdPrint) RENVOYER Status Status = tPRINTER[1]:Status API("winspool.drv","ClosePrinter", hdPrint) RENVOYER Status // peut etre un OuBinaire des constantes "Graviere Julien" <gravierejulien@yahoo.fr> a écrit dans le message de news: 44f3e771$1@news.pcsoft.fr... Ce message à l'attention de Philippe Pasquali ou tout autre developpeur ayant eu besoin du code ci-après :
Suite au code posté sur le Forum le 15/06/2005, je tente d'obtenir le statut de mon imprimante et cela ne fonctionne pas : même quand l'imprimante est en erreur, le code me renvoie 0 (tout est ok). Je ne comprends pas cette ligne : Etat = tSTATUS[1]:status //Pourquoi un indice de 1? //Pourquoi ce n'est pas dynamique //Puis je avoir plus d'explication?
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END ----------------------------------------------------------------------------------------------- pPrinterName est une chaîne ASCIIZ sur 256 = pPrinter phPrinter est un entier = 0 pcbNeeded est un entier = 0 RetCode est un entier tSTATUS est un tableau dynamique de 100 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 2048 Etat est un entier = 0 Req est une chaîne InfoErreur est une chaîne ------------------------------------------------------------------------------------------- SI API( "winspool.drv" ,"OpenPrinterA", pPrinterName, &phPrinter, Null) <> 0 ALORS RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, 0,&pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS,pcbNeeded, &pcbNeeded) SI RetCode<>0 ALORS Etat = tSTATUS[1]:status FIN API("winspool.drv", "ClosePrinter", phPrinter) FIN
> |
| | | |
|
| | |
| |
| Posté le 29 août 2006 - 12:13 par philippe.pasquali dans |
Depuis j'avais modifié le bazard (sans le dire : pas bien çà) j'utilise PRINTER_INFO_6 qui est plus adaptée à ce type de fonction
//**************************** CONSTANT // STATUT D'UNE IMPRIMANTE................... // Peut etre une combinaison de ces valeurs PRINTER_STATUS_PAUSED = 0x00000001 PRINTER_STATUS_ERROR = 0x00000002 PRINTER_STATUS_PENDING_DELETION = 0x00000004 PRINTER_STATUS_PAPER_JAM = 0x00000008 PRINTER_STATUS_PAPER_OUT = 0x00000010 PRINTER_STATUS_MANUAL_FEED = 0x00000020 PRINTER_STATUS_PAPER_PROBLEM = 0x00000040 PRINTER_STATUS_OFFLINE = 0x00000080 PRINTER_STATUS_IO_ACTIVE = 0x00000100 PRINTER_STATUS_BUSY = 0x00000200 PRINTER_STATUS_PRINTING = 0x00000400 PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800 PRINTER_STATUS_NOT_AVAILABLE = 0x00001000 PRINTER_STATUS_WAITING = 0x00002000 PRINTER_STATUS_PROCESSING = 0x00004000 PRINTER_STATUS_INITIALIZING = 0x00008000 PRINTER_STATUS_WARMING_UP = 0x00010000 PRINTER_STATUS_TONER_LOW = 0x00020000 PRINTER_STATUS_NO_TONER = 0x00040000 PRINTER_STATUS_PAGE_PUNT = 0x00080000 PRINTER_STATUS_USER_INTERVENTION = 0x00100000 PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000 PRINTER_STATUS_DOOR_OPEN = 0x00400000 PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000 PRINTER_STATUS_POWER_SAVE = 0x01000000 INVALID_PRINTER = 0x10000000 END
//**************************** _PRINTER_INFO_6 est une structure Status est un entier END
//**************************** // Renvoie le status d'une imprimante //**************************** FUNCTION iGetStatus(pPrinterName=iInfoImprimante())
Status, hdPrint, Ret, cbBuf, pcbNeeded sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName tPRINTER est une x_PRINTER_INFO_6 PRINTER_INFO_LEVEL est un entier = 6 Buf est une chaîne ASCIIZ sur 1024 Status = INVALID_PRINTER
// Ouverture du handle avec l'imprimante Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER Status
// Execution de la fonction une fois avec 0 pour connaitre le nombre exact cbBuf = 0 pcbNeeded = 0 API( "winspool.drv", "GetPrinterA", hdPrint, PRINTER_INFO_LEVEL, &tPRINTER, cbBuf, &pcbNeeded)
// Met le nombre renvoyer par le premier appel cbBuf = pcbNeeded Ret = API( "winspool.drv", "GetPrinterA", hdPrint, PRINTER_INFO_LEVEL, &tPRINTER, cbBuf, &pcbNeeded) IF Ret = 0 THEN API("winspool.drv","ClosePrinter", hdPrint) RENVOYER Status END
Status = tPRINTER:Status
API("winspool.drv","ClosePrinter", hdPrint)
RENVOYER Status
Status = tPRINTER[1]:Status
API("winspool.drv","ClosePrinter", hdPrint)
RENVOYER Status // peut etre un OuBinaire des constantes
"Graviere Julien" <gravierejulien@yahoo.fr> a écrit dans le message de news: 44f3e771$1@news.pcsoft.fr...
Ce message à l'attention de Philippe Pasquali ou tout autre developpeur ayant eu besoin du code ci-après :
Suite au code posté sur le Forum le 15/06/2005, je tente d'obtenir le statut de mon imprimante et cela ne fonctionne pas : même quand l'imprimante est en erreur, le code me renvoie 0 (tout est ok). Je ne comprends pas cette ligne : Etat = tSTATUS[1]:status //Pourquoi un indice de 1? //Pourquoi ce n'est pas dynamique //Puis je avoir plus d'explication?
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END ----------------------------------------------------------------------------------------------- pPrinterName est une chaîne ASCIIZ sur 256 = pPrinter phPrinter est un entier = 0 pcbNeeded est un entier = 0 RetCode est un entier tSTATUS est un tableau dynamique de 100 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 2048 Etat est un entier = 0 Req est une chaîne InfoErreur est une chaîne ------------------------------------------------------------------------------------------- SI API( "winspool.drv" ,"OpenPrinterA", pPrinterName, &phPrinter, Null) <> 0 ALORS RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, 0,&pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS,pcbNeeded, &pcbNeeded) SI RetCode<>0 ALORS Etat = tSTATUS[1]:status FIN API("winspool.drv", "ClosePrinter", phPrinter) FIN >
|
| | | |
|
| | |
| |
| Posté le 29 août 2006 - 11:33 par gravierejulien dans |
Ce message à l'attention de Philippe Pasquali ou tout autre developpeur ayant eu besoin du code ci-après :
Suite au code posté sur le Forum le 15/06/2005, je tente d'obtenir le statut de mon imprimante et cela ne fonctionne pas : même quand l'imprimante est en erreur, le code me renvoie 0 (tout est ok). Je ne comprends pas cette ligne : Etat = tSTATUS[1]:status //Pourquoi un indice de 1? //Pourquoi ce n'est pas dynamique //Puis je avoir plus d'explication?
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END ----------------------------------------------------------------------------------------------- pPrinterName est une chaîne ASCIIZ sur 256 = pPrinter phPrinter est un entier = 0 pcbNeeded est un entier = 0 RetCode est un entier tSTATUS est un tableau dynamique de 100 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 2048 Etat est un entier = 0 Req est une chaîne InfoErreur est une chaîne ------------------------------------------------------------------------------------------- SI API( "winspool.drv" ,"OpenPrinterA", pPrinterName, &phPrinter, Null) <> 0 ALORS RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, 0,&pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS,pcbNeeded, &pcbNeeded) SI RetCode<>0 ALORS Etat = tSTATUS[1]:status FIN API("winspool.drv", "ClosePrinter", phPrinter) >FIN |
| | | |
|
| | |
| |
| Posté le 13 juillet 2005 - 19:02 par philippe.pasquali dans |
Voici une collection de procedure qui peut t'aider Regarde surtout la fonction PRINTEREnumPrinter()
//-------------------DECLARATION DE LA COLLECTION CONSTANT // ATTRIBUT D'UNE IMPRIMANTE................... // Peut etre une combinaison de ces valeurs PRINTER_ATTRIBUTE_QUEUED = 0x00000001 // If set, the printer spools and starts printing after the last page is spooled. If not set and PRINTER_ATTRIBUTE_DIRECT is not set, the printer spools and prints while spooling. PRINTER_ATTRIBUTE_DIRECT = 0x00000002 // Job is sent directly to the printer (it is not spooled). PRINTER_ATTRIBUTE_DEFAULT = 0x00000004 // Windows 95/98/Me: Indicates the printer is the default printer in the system. PRINTER_ATTRIBUTE_SHARED = 0x00000008 // Printer is shared. PRINTER_ATTRIBUTE_NETWORK = 0x00000010 // Printer is a network printer connection. PRINTER_ATTRIBUTE_HIDDEN = 0x00000020 // Reserved. PRINTER_ATTRIBUTE_LOCAL = 0x00000040 // Printer is a local printer. PRINTER_ATTRIBUTE_ENABLE_DEVQ = 0x00000080 // If set, DevQueryPrint is called. DevQueryPrint may fail if the document and printer setups do not match. Setting this flag causes mismatched documents to be held in the queue. PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 0x00000100 // If set, jobs are kept after they are printed. If unset, jobs are deleted. PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x00000200 // If set and printer is set for print-while-spooling, any jobs that have completed spooling are scheduled to print before jobs that have not completed spooling. PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x00000400 // Windows 95/98/Me: Indicates whether the printer is currently connected. If the printer is not currently connected, print jobs will continue to spool. PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x00000800 // Windows 95/98/Me: Indicates whether bi-directional communications are enabled for the printer. PRINTER_ATTRIBUTE_RAW_ONLY = 0x00001000 // Indicates that only raw data type print jobs can be spooled. PRINTER_ATTRIBUTE_PUBLISHED = 0x00002000 // Windows 2000/XP: Indicates whether the printer is published in the directory service. // Ici j'suis pas sur du tout comme il n'existait pas dans la version du winspool.h j'e l'ai extrapolé des valeurs précédentes PRINTER_ATTRIBUTE_FAX = 0x00004000 // Windows XP: If set, printer is a fax printer. This can only be set by AddPrinter, but it can be retrieved by EnumPrinters and GetPrinter.
// STATUT D'UNE IMPRIMANTE................... // Peut etre une combinaison de ces valeurs PRINTER_STATUS_PAUSED = 0x00000001 PRINTER_STATUS_ERROR = 0x00000002 PRINTER_STATUS_PENDING_DELETION = 0x00000004 PRINTER_STATUS_PAPER_JAM = 0x00000008 PRINTER_STATUS_PAPER_OUT = 0x00000010 PRINTER_STATUS_MANUAL_FEED = 0x00000020 PRINTER_STATUS_PAPER_PROBLEM = 0x00000040 PRINTER_STATUS_OFFLINE = 0x00000080 PRINTER_STATUS_IO_ACTIVE = 0x00000100 PRINTER_STATUS_BUSY = 0x00000200 PRINTER_STATUS_PRINTING = 0x00000400 PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800 PRINTER_STATUS_NOT_AVAILABLE = 0x00001000 PRINTER_STATUS_WAITING = 0x00002000 PRINTER_STATUS_PROCESSING = 0x00004000 PRINTER_STATUS_INITIALIZING = 0x00008000 PRINTER_STATUS_WARMING_UP = 0x00010000 PRINTER_STATUS_TONER_LOW = 0x00020000 PRINTER_STATUS_NO_TONER = 0x00040000 PRINTER_STATUS_PAGE_PUNT = 0x00080000 PRINTER_STATUS_USER_INTERVENTION = 0x00100000 PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000 PRINTER_STATUS_DOOR_OPEN = 0x00400000 PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000 PRINTER_STATUS_POWER_SAVE = 0x01000000
JOB_STATUS_PAUSED = 0x00000001 // Job is paused. JOB_STATUS_ERROR = 0x00000002 // An error is associated with the job. JOB_STATUS_DELETING = 0x00000004 // Job is being deleted. JOB_STATUS_SPOOLING = 0x00000008 // Job is spooling. JOB_STATUS_PRINTING = 0x00000010 // Job is printing. JOB_STATUS_OFFLINE = 0x00000020 // Printer is offline. JOB_STATUS_PAPEROUT = 0x00000040 // Printer is out of paper. JOB_STATUS_PRINTED = 0x00000080 // Job has printed. JOB_STATUS_DELETED = 0x00000100 // Job has been deleted. JOB_STATUS_BLOCKED_DEVQ = 0x00000200 // The driver cannot print the job. JOB_STATUS_USER_INTERVENTION = 0x00000400 // Printer has an error that requires the user to do something. JOB_STATUS_RESTART = 0x00000800 // Job has been restarted. JOB_STATUS_COMPLETE = 0x00001000 // Windows XP: Job is sent to the printer, but the job may not be printed yet. See Remarks for more information.
JOB_CONTROL_PAUSE = 1 JOB_CONTROL_RESUME = 2 JOB_CONTROL_CANCEL = 3 JOB_CONTROL_RESTART = 4 JOB_CONTROL_DELETE = 5 JOB_CONTROL_SENT_TO_PRINTER = 6 JOB_CONTROL_LAST_PAGE_EJECTED = 7
NO_PRIORITY = 0 MAX_PRIORITY = 99 MIN_PRIORITY = 1 DEF_PRIORITY = 1
PRINTER_ENUM_DEFAULT = 0x00000001 PRINTER_ENUM_LOCAL = 0x00000002 PRINTER_ENUM_CONNECTIONS = 0x00000004 PRINTER_ENUM_FAVORITE = 0x00000004 PRINTER_ENUM_NAME = 0x00000008 PRINTER_ENUM_REMOTE = 0x00000010 PRINTER_ENUM_SHARED = 0x00000020 PRINTER_ENUM_NETWORK = 0x00000040 PRINTER_ENUM_EXPAND = 0x00004000 PRINTER_ENUM_CONTAINER = 0x00008000 PRINTER_ENUM_ICONMASK = 0x00ff0000 PRINTER_ENUM_ICON1 = 0x00010000 PRINTER_ENUM_ICON2 = 0x00020000 PRINTER_ENUM_ICON3 = 0x00040000 PRINTER_ENUM_ICON4 = 0x00080000 PRINTER_ENUM_ICON5 = 0x00100000 PRINTER_ENUM_ICON6 = 0x00200000 PRINTER_ENUM_ICON7 = 0x00400000 PRINTER_ENUM_ICON8 = 0x00800000 PRINTER_ENUM_HIDE = 0x01000000
END
x_SYSTEM_TIME est une structure wYear est un entier sans signe sur 2 octets wMonth est un entier sans signe sur 2 octets wDayOfWeek est un entier sans signe sur 2 octets wDay est un entier sans signe sur 2 octets wHour est un entier sans signe sur 2 octets wMinute est un entier sans signe sur 2 octets wSecond est un entier sans signe sur 2 octets wMilliseconds est un entier sans signe sur 2 octets END
x_JOB_INFO_1 est une structure JobId est un entier // N° job pPrinterName est un entier // Pointer Name of the printer for which the job is spooled pMachineName est un entier // Pointer Name of the machine that created the print job. pUserName est un entier // Pointer Name of the user who owns the print job. pDocument est un entier // Pointer Name of the print job (for example, "MS-WORD: Review.doc"). pDatatype est un entier // Pointer Type of data used to record the print job. pStatus est un entier // Pointer to a null-terminated string that specifies the status of the print job. // This member should be checked prior to Status and, if pStatus is NULL, the status // is defined by the contents of the Status member. Status est un entier // Specifies the job status Priority est un entier // Specifies the job priority. This member can be one of the following values or in the range between 1 through 99 (MIN_PRIORITY through MAX_PRIORITY). Positi est un entier // Specifies the job's position in the print queue. TotalPages est un entier // Specifies how many pages the document contains. This value may be zero if the print job does not contain page delimiting information. PagesPrinted est un entier // Specifies the number of pages that have printed. This value may be zero if the print job does not contain page delimiting information. Submitted est une x_SYSTEM_TIME // A SYSTEMTIME structure that specifies the time that this document was spooled END
x_PRINTER_INFO_1 est une structure Flags est un entier pDescription est un entier pPrinterName est un entier pComment est un entier END
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END
//----------------------------------------------------- // Renvoie une chaine séparateur TAB avec le nom des fichiers en attente d'impression dans le spool de l'imprimante FUNCTION GetJobInPrinter(pPrinterName=iInfoImprimante())
hdPrint, nbDoc, i, pcbNeeded, Ret sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau dynamique de 200 x_JOB_INFO_1
// Ouverture du handle avec l'imprimante Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER ListeDesFichiers
// Lance une fois pour obtenir le nombre d'octet dont on a besoin Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, 1, &pcbNeeded, &nbDoc)
// Lance une seconde fois pour obtenir le nombre de job dans la file d'attente Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER ListeDesFichiers END
// nbDoc contient le nombre de document IF nbDoc=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER "" END
// tJOB la liste des jobs FOR i=1 TO nbDoc WHEN EXCEPTION IN Transfert(&Buf,tJOB[i]:pDocument,2047) ListeDesFichiers += Buf+TAB DO ListeDesFichiers = "" SORTIR END END
API( "winspool.drv", "ClosePrinter" , hdPrint)
RENVOYER ListeDesFichiers
//----------------------------------------------------- // Renvoie le nombre de job d'une file d'attente d'imprimante FUNCTION PRINTERGetNumberOfJob(pPrinterName=iInfoImprimante())
hdPrint, nbDoc, pcbNeeded, Ret sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName tJOB est un tableau dynamique de 200 x_JOB_INFO_1
nbDoc = 0 Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER nbDoc API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, 1, &pcbNeeded, &nbDoc) API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) API( "winspool.drv", "ClosePrinter" , hdPrint) Dimension(tJOB,0) RENVOYER nbDoc
//----------------------------------------------------- // Renvoie une chaine de caractère avec une ligne séparateur crlf pour chaque imprimante // déclarée sur le poste dont on donne le nom // Pour chaque imprimante, les informations sont séparées par TAB // Les informations sont les suivantes :
// Nom du serveur sur lequel l'imprimante est installée ex : \\ServeurName // Nom complet de l'imprimante ex: \\ServeurName\PrinterName // Nom de partage de l'imprimante // Port ex: LPT1: ou IP_10.0.176.128 // Nom du driver ex: Generic / Text Only ou Lexmark E332n // Commentaires ex: Comptabilité // Localisation ex: Informatique // Nom du proceseur d'impression ex: WinPrint ou Lexmark PCL Print Processor // Type d'impression ex: RAW // Attribut de l'imprimante VOIR LA LISTE DES CONSTANTES : PRINTER_ATTRIBUTE_xxxxxxxxxx // Nombre de job présent dans la file d'attente // Le status de l'imprimante VOIR LA LISTE DES CONSTANTES : PRINTER_STATUS_xxxxxxxxxx // FUNCTION PRINTEREnumPrinter() Level, pcbNeeded, pcReturned, Ret, i , Flag sont des entiers tPRINTER est un tableau de 3000 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 1024 ComputerName est une chaîne ASCIIZ sur 128 = "\\" + NetNomMachine() ListeImprimante est une chaîne = ""
Flag = OUBinaire(PRINTER_ENUM_LOCAL,PRINTER_ENUM_CONNECTIONS) Level = 2; pcbNeeded = 0; pcReturned = 0
// Appel une fois la fonction avec 0 pour connaitre le nombre d'octet nessecaire (renvoyé dans pcNeeded) API("winspool.drv","EnumPrintersA", Flag, &ComputerName, Level, &tPRINTER, 0 , &pcbNeeded, &pcReturned)
// Appel une seconde fois avec la bonne valeur Ret = API("winspool.drv","EnumPrintersA", Flag, &ComputerName, Level, &tPRINTER, pcbNeeded, &pcbNeeded, &pcReturned) IF Ret=1 THEN // C'est bon pcReturned contient le nombre d'imprimante donc le nombre de structure valide dans le tableau FOR i=1 TO pcReturned IF ListeImprimante <> "" THEN ListeImprimante += CRLF Transfert(&Buf,tPRINTER[i]:pServerName,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pPrinterName,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pShareName,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pPortName,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pDriverName,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pComment,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pLocation,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pPrintProcessor,1023); ListeImprimante += Buf+TAB Transfert(&Buf,tPRINTER[i]:pDatatype,1023); ListeImprimante += Buf+TAB ListeImprimante += NumériqueVersChaine(tPRINTER[i]:Attributes)+TAB ListeImprimante += NumériqueVersChaine(tPRINTER[i]:cJobs)+TAB ListeImprimante += NumériqueVersChaine(tPRINTER[i]:Status) END END
RENVOYER ListeImprimante
//----------------------------------------------------- FUNCTION PRINTERDeleteAllJob(pPrinter) hdPrint, nbDoc, i, pcbNeeded, Ret, Level sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinter Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau de 300 x_JOB_INFO_1 Level = 1
// Ouverture du handle avec l'imprimante Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER False
// Lance une fois pour obtenir le nombre d'octet dont on a besoin Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, Level, &tJOB, 1, &pcbNeeded, &nbDoc)
// Lance une seconde fois pour obtenir le nombre de job dans la file d'attente Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, Level, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False
// nbDoc contient le nombre de document IF nbDoc=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False
// tJOB la liste des jobs FOR i=1 TO nbDoc // Lance l'effacement du job Ret = API("winspool.drv","SetJobA", hdPrint, tJOB[i]:jobid, Level, &tJOB, JOB_CONTROL_DELETE) IF Ret = 0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False END
API( "winspool.drv", "ClosePrinter" , hdPrint)
RENVOYER True
//----------------------------------------------------- FUNCTION PRINTERPauseAllJob(pPrinter) hdPrint, nbDoc, i, pcbNeeded, Ret, Level sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinter Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau de 300 x_JOB_INFO_1 Level = 1
// Ouverture du handle avec l'imprimante Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER False
// Lance une fois pour obtenir le nombre d'octet dont on a besoin Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, Level, &tJOB, 1, &pcbNeeded, &nbDoc)
// Lance une seconde fois pour obtenir le nombre de job dans la file d'attente Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, Level, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False
// nbDoc contient le nombre de document IF nbDoc=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False
// tJOB la liste des jobs FOR i=1 TO nbDoc // Lance l'effacement du job Ret = API("winspool.drv","SetJobA", hdPrint, tJOB[i]:jobid, Level, &tJOB, JOB_CONTROL_PAUSE) IF Ret <> 0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False END
API( "winspool.drv", "ClosePrinter" , hdPrint)
RENVOYER True
//----------------------------------------------------- FUNCTION PRINTERResumeAllJob(pPrinter) hdPrint, nbDoc, i, pcbNeeded, Ret, Level sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinter Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau de 300 x_JOB_INFO_1 Level = 1
// Ouverture du handle avec l'imprimante Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER False
// Lance une fois pour obtenir le nombre d'octet dont on a besoin Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, Level, &tJOB, 1, &pcbNeeded, &nbDoc)
// Lance une seconde fois pour obtenir le nombre de job dans la file d'attente Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, Level, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False
// nbDoc contient le nombre de document IF nbDoc=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False
// tJOB la liste des jobs FOR i=1 TO nbDoc // Lance l'effacement du job Ret = API("winspool.drv","SetJobA", hdPrint, tJOB[i]:jobid, Level, &tJOB, JOB_CONTROL_RESUME) IF Ret <> 0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint); RENVOYER False END
API( "winspool.drv", "ClosePrinter" , hdPrint)
RENVOYER True
//----------------------------------------------------- // pPrinterName est une chaine = \\ServeurName\PrinterName PROCEDURE PRINTERAddPrinter(pPrinterName) PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName >RENVOYER (API("winspool.drv","AddPrinterConnectionA", &pPrinterName)=1) |
| | | |
|
| | |
| |
| Posté le 16 juin 2005 - 18:53 par philippe.pasquali dans |
Bonjour je ne sais pas si cela peut t'aider mais voila du code sur lequel je suis en train de bosser P.S. j'ai mis ça dans une collection de procédure
------------------------------------------------------- CODE DE DECLARATION DE LA COLLECTION ------------------------------------------------------- CONSTANT PRINTER_ENUM_DEFAULT = 0x00000001 PRINTER_ENUM_LOCAL = 0x00000002 PRINTER_ENUM_CONNECTIONS = 0x00000004 PRINTER_ENUM_FAVORITE = 0x00000004 PRINTER_ENUM_NAME = 0x00000008 PRINTER_ENUM_REMOTE = 0x00000010 PRINTER_ENUM_SHARED = 0x00000020 PRINTER_ENUM_NETWORK = 0x00000040 PRINTER_ENUM_EXPAND = 0x00004000 PRINTER_ENUM_CONTAINER = 0x00008000 PRINTER_ENUM_ICONMASK = 0x00ff0000 PRINTER_ENUM_ICON1 = 0x00010000 PRINTER_ENUM_ICON2 = 0x00020000 PRINTER_ENUM_ICON3 = 0x00040000 PRINTER_ENUM_ICON4 = 0x00080000 PRINTER_ENUM_ICON5 = 0x00100000 PRINTER_ENUM_ICON6 = 0x00200000 PRINTER_ENUM_ICON7 = 0x00400000 PRINTER_ENUM_ICON8 = 0x00800000 PRINTER_ENUM_HIDE = 0x01000000
JOB_STATUS_PAUSED = 0x00000001 // Job is paused. JOB_STATUS_ERROR = 0x00000002 // An error is associated with the job. JOB_STATUS_DELETING = 0x00000004 // Job is being deleted. JOB_STATUS_SPOOLING = 0x00000008 // Job is spooling. JOB_STATUS_PRINTING = 0x00000010 // Job is printing. JOB_STATUS_OFFLINE = 0x00000020 // Printer is offline. JOB_STATUS_PAPEROUT = 0x00000040 // Printer is out of paper. JOB_STATUS_PRINTED = 0x00000080 // Job has printed. JOB_STATUS_DELETED = 0x00000100 // Job has been deleted. JOB_STATUS_BLOCKED_DEVQ = 0x00000200 // The driver cannot print the job. JOB_STATUS_USER_INTERVENTION = 0x00000400 // Printer has an error that requires the user to do something. JOB_STATUS_RESTART = 0x00000800 // Job has been restarted. JOB_STATUS_COMPLETE = 0x00001000 // Windows XP: Job is sent to the printer, but the job may not be printed yet. See Remarks for more information.
NO_PRIORITY = 0 MAX_PRIORITY = 99 MIN_PRIORITY = 1 DEF_PRIORITY = 1
PRINTER_STATUS_PAUSED = 0x00000001 PRINTER_STATUS_ERROR = 0x00000002 PRINTER_STATUS_PENDING_DELETION = 0x00000004 PRINTER_STATUS_PAPER_JAM = 0x00000008 PRINTER_STATUS_PAPER_OUT = 0x00000010 PRINTER_STATUS_MANUAL_FEED = 0x00000020 PRINTER_STATUS_PAPER_PROBLEM = 0x00000040 PRINTER_STATUS_OFFLINE = 0x00000080 PRINTER_STATUS_IO_ACTIVE = 0x00000100 PRINTER_STATUS_BUSY = 0x00000200 PRINTER_STATUS_PRINTING = 0x00000400 PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800 PRINTER_STATUS_NOT_AVAILABLE = 0x00001000 PRINTER_STATUS_WAITING = 0x00002000 PRINTER_STATUS_PROCESSING = 0x00004000 PRINTER_STATUS_INITIALIZING = 0x00008000 PRINTER_STATUS_WARMING_UP = 0x00010000 PRINTER_STATUS_TONER_LOW = 0x00020000 PRINTER_STATUS_NO_TONER = 0x00040000 PRINTER_STATUS_PAGE_PUNT = 0x00080000 PRINTER_STATUS_USER_INTERVENTION = 0x00100000 PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000 PRINTER_STATUS_DOOR_OPEN = 0x00400000 PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000 PRINTER_STATUS_POWER_SAVE = 0x01000000 END
x_SYSTEM_TIME est une structure wYear est un entier sans signe sur 2 octets wMonth est un entier sans signe sur 2 octets wDayOfWeek est un entier sans signe sur 2 octets wDay est un entier sans signe sur 2 octets wHour est un entier sans signe sur 2 octets wMinute est un entier sans signe sur 2 octets wSecond est un entier sans signe sur 2 octets wMilliseconds est un entier sans signe sur 2 octets END
x_JOB_INFO_1 est une structure JobId est un entier // N° du job dans le spool pPrinterName est un entier // Pointer Name of the printer for which the job is spooled pMachineName est un entier // Pointer Name of the machine that created the print job. pUserName est un entier // Pointer Name of the user who owns the print job. pDocument est un entier // Pointer Name of the print job (for example, "MS-WORD: Review.doc"). pDatatype est un entier // Pointer Type of data used to record the print job. pStatus est un entier //Pointer to a null-terminated string that specifies the status of the print job. //This member should be checked prior to Status and, if pStatus is NULL, the status //is defined by the contents of the Status member. Status est un entier //Specifies the job status Priority est un entier //Specifies the job priority. This member can be one of the following values or in the range between 1 through 99 (MIN_PRIORITY through MAX_PRIORITY). Positi est un entier //Specifies the job's position in the print queue. TotalPages est un entier //Specifies how many pages the document contains. This value may be zero if the print job does not contain page delimiting information. PagesPrinted est un entier //Specifies the number of pages that have printed. This value may be zero if the print job does not contain page delimiting information. Submitted est une x_SYSTEM_TIME //A SYSTEMTIME structure that specifies the time that this document was spooled END
x_PRINTER_INFO_1 est une structure Flags est un entier pDescription est un entier pName est un entier pComment est un entier END
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END
------------------------------------------------------------- // Retourne la liste des imprimantes installée sur un ordinateur // pour le moment je ne récupére pas ce qui est installé localement FUNCTION PRINTEREnumPrinter(pComputerName) ComputerName est une chaîne ASCIIZ sur 128 = pComputerName tPRINTER est un tableau dynamique de 3000 x_PRINTER_INFO_2 pcbNeeded est un entier = 0 pcReturned est un entier = 0 Ret est un entier Buf est une chaîne ASCIIZ sur 1024 ListeImprimante est une chaîne = "" i est un entier Flag est un entier = PRINTER_ENUM_NAME
IF ComputerName[[1 sur 2]] <> "\\" THEN ComputerName = "\\" + ComputerName API("winspool.drv","EnumPrintersA", Flag, &ComputerName,2,&tPRINTER,0,&pcbNeeded,&pcReturned) Ret = API("winspool.drv","EnumPrintersA", Flag, &ComputerName, 2, &tPRINTER, pcbNeeded, &pcbNeeded, &pcReturned) IF Ret=1 THEN FOR i=1 TO pcReturned
IF ListeImprimante <> "" THEN ListeImprimante += CRLF
// Le nom complet Transfert(&Buf,tPRINTER[i]:pPrinterName,1023); ListeImprimante += Buf+TAB // Le commentaire Transfert(&Buf,tPRINTER[i]:pComment,1023); ListeImprimante += Buf+TAB // Le local Transfert(&Buf,tPRINTER[i]:pLocation,1023); ListeImprimante += Buf
END END
RENVOYER ListeImprimante
--------------------------------------------------------------- // Renvoie une chaine séparateur TAB avec le nom des fichiers // en attente d'impression dans le spool de l'imprimante FUNCTION GetJobInPrinter(pPrinterName=iInfoImprimante())
hdPrint, nbDoc, i, pcbNeeded, Ret sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau dynamique de 200 x_JOB_INFO_1
// Ouverture du handle avec l'imprimante Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER ListeDesFichiers
// Lance une fois pour obtenir le nombre d'octet dont on a besoin Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, 1, &pcbNeeded, &nbDoc)
// Lance une seconde fois pour obtenir le nombre de job dans la file d'attente Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER ListeDesFichiers END
// nbDoc contient le nombre de document IF nbDoc=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER "" END
// tJOB la liste des jobs FOR i=1 TO nbDoc WHEN EXCEPTION IN Transfert(&Buf,tJOB[i]:pDocument,2047) ListeDesFichiers += Buf+TAB DO ListeDesFichiers = "" SORTIR END END
API( "winspool.drv", "ClosePrinter" , hdPrint)
RENVOYER ListeDesFichiers
---------------------------------------------------------------------------- -- // Renvoie le nombre de job d'une file d'attente d'imprimante FUNCTION PRINTERGetNumberOfJob(pPrinterName=iInfoImprimante())
hdPrint, nbDoc, pcbNeeded, Ret sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName tJOB est un tableau dynamique de 200 x_JOB_INFO_1
nbDoc = 0 Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER nbDoc API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, 1, &pcbNeeded, &nbDoc) API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) API( "winspool.drv", "ClosePrinter" , hdPrint) Dimension(tJOB,0) RENVOYER nbDoc
---------------------------------------------------------------------------- -- FUNCTION PRINTERGetStatus(pPrinter=iInfoImprimante()) pPrinterName est une chaîne ASCIIZ sur 256 = pPrinter phPrinter est un entier = 0 pcbNeeded est un entier = 0 RetCode est un entier tSTATUS est un tableau dynamique de 100 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 2048 Etat est un entier = 0
// Ouverture du lien vers l'imprimante phPrinter = handle sur l'imprimante IF API( "winspool.drv" ,"OpenPrinterA", pPrinterName, &phPrinter, Null) <> 0 THEN RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, 0, &pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, pcbNeeded, &pcbNeeded) IF RetCode<>0 THEN Etat = tSTATUS[1]:status END API("winspool.drv", "ClosePrinter", phPrinter) END RENVOYER Etat
"Eric" <epaziot@domoform.fr> a écrit dans le message de news:42b17181$1@news.pcsoft.fr...
Bonjour,
J'ai créer une imprimante sur un port redirigé qui lance mon application.
Je récupère les infos avec "EnumJobsA". Jusque la pas de Pb..............................
Mais, je sèche complètement pour recupèrer à coup sur et de façon propre
le spool.
Le but de mon appli est de reformater des impressions en textes provenants
de # systèmes.
CORDIALEMENT
Eric
>
|
| | | |
|
| | |
| |
| Posté le 13 juin 2005 - 18:10 par philippe.pasquali dans |
Désolé j'ai mis un peut de temps mais voila le bazard une collection de procédure PRINTER il y a du rab FUNCTION PRINTERGetStatus(pPrinter=iInfoImprimante()) Etat d'une imprimante d'un réseau ou local FUNCTION GetJobInPrinter(pPrinterName=iInfoImprimante()) Liste des jobs dans la file d'attente d'une imprimante FUNCTION PRINTERGetNumberOfJob(pPrinterName=iInfoImprimante()) Nombre de job dans la file d'attente d'une imprimante
------------------- DECLARATION ------------------- CONSTANT PRINTER_ENUM_DEFAULT = 0x00000001 PRINTER_ENUM_LOCAL = 0x00000002 PRINTER_ENUM_CONNECTIONS = 0x00000004 PRINTER_ENUM_FAVORITE = 0x00000004 PRINTER_ENUM_NAME = 0x00000008 PRINTER_ENUM_REMOTE = 0x00000010 PRINTER_ENUM_SHARED = 0x00000020 PRINTER_ENUM_NETWORK = 0x00000040 PRINTER_ENUM_EXPAND = 0x00004000 PRINTER_ENUM_CONTAINER = 0x00008000 PRINTER_ENUM_ICONMASK = 0x00ff0000 PRINTER_ENUM_ICON1 = 0x00010000 PRINTER_ENUM_ICON2 = 0x00020000 PRINTER_ENUM_ICON3 = 0x00040000 PRINTER_ENUM_ICON4 = 0x00080000 PRINTER_ENUM_ICON5 = 0x00100000 PRINTER_ENUM_ICON6 = 0x00200000 PRINTER_ENUM_ICON7 = 0x00400000 PRINTER_ENUM_ICON8 = 0x00800000 PRINTER_ENUM_HIDE = 0x01000000
JOB_STATUS_PAUSED = 0x00000001 // Job is paused. JOB_STATUS_ERROR = 0x00000002 // An error is associated with the job. JOB_STATUS_DELETING = 0x00000004 // Job is being deleted. JOB_STATUS_SPOOLING = 0x00000008 // Job is spooling. JOB_STATUS_PRINTING = 0x00000010 // Job is printing. JOB_STATUS_OFFLINE = 0x00000020 // Printer is offline. JOB_STATUS_PAPEROUT = 0x00000040 // Printer is out of paper. JOB_STATUS_PRINTED = 0x00000080 // Job has printed. JOB_STATUS_DELETED = 0x00000100 // Job has been deleted. JOB_STATUS_BLOCKED_DEVQ = 0x00000200 // The driver cannot print the job. JOB_STATUS_USER_INTERVENTION = 0x00000400 // Printer has an error that requires the user to do something. JOB_STATUS_RESTART = 0x00000800 // Job has been restarted. JOB_STATUS_COMPLETE = 0x00001000 // Windows XP: Job is sent to the printer, but the job may not be printed yet. See Remarks for more information.
NO_PRIORITY = 0 MAX_PRIORITY = 99 MIN_PRIORITY = 1 DEF_PRIORITY = 1
PRINTER_STATUS_PAUSED = 0x00000001 PRINTER_STATUS_ERROR = 0x00000002 PRINTER_STATUS_PENDING_DELETION = 0x00000004 PRINTER_STATUS_PAPER_JAM = 0x00000008 PRINTER_STATUS_PAPER_OUT = 0x00000010 PRINTER_STATUS_MANUAL_FEED = 0x00000020 PRINTER_STATUS_PAPER_PROBLEM = 0x00000040 PRINTER_STATUS_OFFLINE = 0x00000080 PRINTER_STATUS_IO_ACTIVE = 0x00000100 PRINTER_STATUS_BUSY = 0x00000200 PRINTER_STATUS_PRINTING = 0x00000400 PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800 PRINTER_STATUS_NOT_AVAILABLE = 0x00001000 PRINTER_STATUS_WAITING = 0x00002000 PRINTER_STATUS_PROCESSING = 0x00004000 PRINTER_STATUS_INITIALIZING = 0x00008000 PRINTER_STATUS_WARMING_UP = 0x00010000 PRINTER_STATUS_TONER_LOW = 0x00020000 PRINTER_STATUS_NO_TONER = 0x00040000 PRINTER_STATUS_PAGE_PUNT = 0x00080000 PRINTER_STATUS_USER_INTERVENTION = 0x00100000 PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000 PRINTER_STATUS_DOOR_OPEN = 0x00400000 PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000 PRINTER_STATUS_POWER_SAVE = 0x01000000 END
x_SYSTEM_TIME est une structure wYear est un entier sans signe sur 2 octets wMonth est un entier sans signe sur 2 octets wDayOfWeek est un entier sans signe sur 2 octets wDay est un entier sans signe sur 2 octets wHour est un entier sans signe sur 2 octets wMinute est un entier sans signe sur 2 octets wSecond est un entier sans signe sur 2 octets wMilliseconds est un entier sans signe sur 2 octets END
x_JOB_INFO_1 est une structure JobId est un entier // N° job pPrinterName est un entier // Pointer Name of the printer for which the job is spooled pMachineName est un entier // Pointer Name of the machine that created the print job. pUserName est un entier // Pointer Name of the user who owns the print job. pDocument est un entier // Pointer Name of the print job (for example, "MS-WORD: Review.doc"). pDatatype est un entier // Pointer Type of data used to record the print job. pStatus est un entier //Pointer to a null-terminated string that specifies the status of the print job. //This member should be checked prior to Status and, if pStatus is NULL, the status //is defined by the contents of the Status member. Status est un entier //Specifies the job status Priority est un entier //Specifies the job priority. This member can be one of the following values or in the range between 1 through 99 (MIN_PRIORITY through MAX_PRIORITY). Positi est un entier //Specifies the job's position in the print queue. TotalPages est un entier //Specifies how many pages the document contains. This value may be zero if the print job does not contain page delimiting information. PagesPrinted est un entier //Specifies the number of pages that have printed. This value may be zero if the print job does not contain page delimiting information. Submitted est une x_SYSTEM_TIME //A SYSTEMTIME structure that specifies the time that this document was spooled END
x_PRINTER_INFO_2 est une structure pServerName est un entier pPrinterName est un entier pShareName est un entier pPortName est un entier pDriverName est un entier pComment est un entier pLocation est un entier pDevMode est un entier pSepFile est un entier pPrintProcessor est un entier pDatatype est un entier pParameters est un entier pSecurityDescriptor est un entier Attributes est un entier Priority est un entier DefaultPriority est un entier StartTime est un entier UntilTime est un entier Status est un entier cJobs est un entier AveragePPM est un entier END
**************************************************************************** **** // 0 c'est qu'il n'y a aucun problème sinon il faut comparer avec la liste des constantes // PRINTER_STATUS_xxxxxxx en faisant un EtBinaire // Exemple je veux savoir si mon imprimante BROPRT219 installée sur le serveur BROSRV002 a un // problème de toner je fais : // EtatPrinter est un entier = PRINTERGetStatus("\\Brosrv002\BROPRT219") // if ETBinaire(EtatPrinter,PRINTER_STATUS_TONER_LOW)=0 then Info(TonerBas) // FUNCTION PRINTERGetStatus(pPrinter=iInfoImprimante()) pPrinterName est une chaîne ASCIIZ sur 256 = pPrinter phPrinter est un entier = 0 pcbNeeded est un entier = 0 RetCode est un entier tSTATUS est un tableau dynamique de 100 x_PRINTER_INFO_2 Buf est une chaîne ASCIIZ sur 2048 Etat est un entier = 0
// Ouverture du lien vers l'imprimante phPrinter = handle sur l'imprimante IF API( "winspool.drv" ,"OpenPrinterA", pPrinterName, &phPrinter, Null) <> 0 THEN RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, 0, &pcbNeeded) RetCode = API("winspool.drv", "GetPrinterA", phPrinter, 2, &tSTATUS, pcbNeeded, &pcbNeeded) IF RetCode<>0 THEN Etat = tSTATUS[1]:status END API("winspool.drv", "ClosePrinter", phPrinter) END RENVOYER Etat
**************************************************************************** **** // Renvoie une chaine séparateur TAB avec le nom des fichiers // en attente d'impression dans le spool de l'imprimante FUNCTION GetJobInPrinter(pPrinterName=iInfoImprimante())
hdPrint, nbDoc, i, j, pcbNeeded, Ret sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau dynamique de 200 x_JOB_INFO_1
Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER ListeDesFichiers
Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, 1, &pcbNeeded, &nbDoc) Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER ListeDesFichiers END
// nbDoc contient le nombre de document IF nbDoc=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER "" END
// tJOB la liste des jobs FOR i=1 TO nbDoc WHEN EXCEPTION IN Transfert(&Buf,tJOB[i]:pDocument,2047) ListeDesFichiers += Buf+TAB DO ListeDesFichiers = "" SORTIR END END
API( "winspool.drv", "ClosePrinter" , hdPrint)
RENVOYER ListeDesFichiers
**************************************************************************** **** // Renvoie le nombre de job d'une file d'attente d'imprimante FUNCTION PRINTERGetNumberOfJob(pPrinterName=iInfoImprimante()) hdPrint, nbDoc, i, j, pcbNeeded, Ret sont des entiers PrinterName est une chaîne ASCIIZ sur 512 = pPrinterName Buf est une chaîne ASCIIZ sur 2048 = "" ListeDesFichiers est une chaîne = "" tJOB est un tableau dynamique de 200 x_JOB_INFO_1
Ret = API( "winspool.drv", "OpenPrinterA" , &PrinterName, &hdPrint, Null) IF Ret = 0 THEN RENVOYER ListeDesFichiers
Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, 1, &pcbNeeded, &nbDoc) Ret = API( "winspool.drv", "EnumJobsA", hdPrint, 0, 1000, 1, &tJOB, pcbNeeded, &pcbNeeded, &nbDoc) IF Ret=0 THEN API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER 0 END API( "winspool.drv", "ClosePrinter" , hdPrint) RENVOYER nbDoc
"Arnaud Marchais" <a.marchais@autosur.com> a écrit dans le message de news:429f0f1a$1@news.pcsoft.fr...
Bonjour,
Je souhaite savoir comment faire pour connaître l'état d'une imprimante sélectionnée dans un programme en Windev 9. En effet, la fonction iListeImprimante me retourne la liste des imprimantes installées sur le poste où l'application développée est lancée, et lorsque j'utilise la fonction iConfigure sur une imprimante de ces imprimantes, elle me retourne Vrai (et donc m'indique que le changement d'imprimante s'est bien effectué)qu'elle soit en état "prêt", "hors connexion", "connexion impossible" ou encore "accès refusé".
Merci d'avance pour la réponse. >
|
| | | |
|
| | |
| |
| Posté le 26 mars 2005 - 17:54 par gie.cm16 dans |
Bjr, Tu peux toujours regarder du côté des API resultat=API("Winspool.drv","OpenPrinterA",pPrinterName,phPrinter,null) etc...
www.DAUSSY.ORG/WINDEV
"
-- Mieux plusieurs têtes qui trouvent qu'une seule têtes que cherche
"Olivier" <oblottin@tiscali.fr> a écrit dans le message de news: 42441668$1@news.pcsoft.fr...
Bonjour.
Je souhaite simplement avoir une confirmation.
Imaginons qu'on souhaite imprimer un état sur une imprimante, dont le pilote ne gère pas la dimention papier personnalisée - c'est à dire iParamètre ("FORMATPAPIER = DEFINIUTILISATEUR") ne fonctionne pas à cause du pilote. Et oui ! Ce genre d'imprimante existe bien ... même en 2005.
Bref, si on ne peut pas imposer un format papier, il sera alors plus qu'utile de connaitre les formats gérés par la dite imprimante et de son pilote. Le problème, c'est que visiblement ces informations ne sont pas accessibles avec WinDEV 9, et même avec les dernières mises à jour.
Est-ce que je me trompe ? Honnêtement, j'espère que oui.
Y a t'il un autre moyen de connaitre cette informations ? Genre base de registre ou autre ?
Merci d'avance.
>
|
| | | |
|
| | | | |
| | |
|