Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Print Queue Monitor
Message
De
14/01/2005 11:28:30
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Print Queue Monitor
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00977227
Message ID:
00977227
Vues:
46
Hello there, i require a print queue monitor that allows you to show all available printers and how many jobs per printer. The problem is that I need to be able to select each printer and view all the print jobs for that printer. Im struggling with the getjob() and setting the JOB_INFO_n to output the job information. I would idealy like to integrate this code into a form. What i have so far is:

CLEAR ALL
CLOSE ALL
CLEAR
**********************************************************************
* Get List of Printers
**********************************************************************
nNoOfPrinters=APRINTERS(aPrinterList)
FOR n = 1 TO nNoOfPrinters
**********************************************************************
* Declare the API functions
**********************************************************************
DECLARE Integer OpenPrinter in WinSpool.Drv as WS_OpenPrinter ;
String pPrinterName, ;
Integer @phPrinter, ;
String pDefault
DECLARE Integer ClosePrinter in WinSpool.Drv as WS_ClosePrinter ;
Integer hPrinter
DECLARE Integer EnumJobs in WinSpool.Drv as WS_EnumJobs ;
Integer hPrinter, ;
Integer FirstJob, ;
Integer NoJobs, ;
Integer Level, ;
String @pJob, ;
Integer cbBuf, ;
Integer @pcbNeeded, ;
Integer @pcReturned,;
DECLARE Long GetJob in WinSpool.Drv ;
Long hPrinter,;
Long nJobID,;
Long nLevel,;
String @cJobInfo,;
Long nBufSize,;
Long @nBufNeeded
DECLARE Integer GetLastError in WIN32API as WS_GetLastError
**********************************************************************
* Open the printer
**********************************************************************
lcPrinter=aPrinterList[n,1]
lnHandle=0
IF !EMPTY(lcPrinter)
nRetVal=WS_OpenPrinter(@lcPrinter, @lnHandle, 0)
IF nRetVal != 0
* The printer was opened
ELSE
* The call failed call GetLastError() to retrieve the error number then exit program
lcError=WS_GetLastError()
? lcError
RETURN
ENDIF
ENDIF
**********************************************************************
* Get the number of jobs
**********************************************************************
lnNeeded = 0
lnNumberOfJobs = 0
* Get the size of the buffer in lnNeeded
lnOK = WS_EnumJobs( ;
lnHandle, ;
0, 127, 1, ;
.NULL., ;
2, ;
@lnNeeded, ;
@lnNumberOfJobs)
IF lnOK=0 THEN
IF WS_GetLastError() <> 122 && The buffer too small error
lcErrorTxt = ApiError()
=WS_ClosePrinter( lnHandle)
WAIT WINDOW NOWAIT "Error enumerating PrintJobs" + CHR(13) + lcErrorTxt
RETURN -2
ENDIF
ENDIF
* Allocate the buffer
lcBuffer = REPLICATE( CHR(0), lnNeeded)
* Get the number of jobs
lnOK = WS_EnumJobs( ;
lnHandle, ;
0, 127, 1,;
@lcBuffer, ;
@lnNeeded, ;
@lnNeeded, ;
@lnNumberOfJobs )
IF lnOK = 0 THEN
lcErrorTxt = ApiError()
= WS_ClosePrinter( lnHandle )
WAIT WINDOW NOWAIT "Error enumerating PrintJobs" + CHR(13) + lcErrorTxt
RETURN -3
ENDIF
**********************************************************************
* Close the printer
**********************************************************************
nClosePrinter=WS_ClosePrinter(lnHandle)
**********************************************************************
* Display the number of jobs in queue
**********************************************************************
? lcPrinter+" has "+ALLTRIM(STR(lnNumberOfJobs))+" jobs in it's queue"
ENDFOR
RETURN

Any help that you can give me would be really appreciated.

thanks

Phil
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform