Discussion Locked

control printer in a vb program

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is there a way to monitor or control a printer from a vb program? My program sends many print jobs to a printer at a much faster rate than they get printed. Thus, the print queue eventually becomes huge and the program crashes. Is there a way to monitor when the print queue gets too large so that I can stop sending print jobs and then resend them once the queue gets smaller?

Any help is greatly appreciated.
Chris

5 replies

by shubens

Hi,
In vb, I don't know but in win32 api I use the function EnumJobs like
/* Get job storage space */
if (!EnumJobs(hPrinter, 0, pPrinterInfo->cJobs, 2, NULL, 0, (LPDWORD)&cByteNeeded, (LPDWORD)&nReturned))
{ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{ free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
}
if Its return error is ERROR_INSUFFICIENT_BUFFER, you could increase buffer size by the same function. I hope this can help you.

by czar andy

Yes, the VB API call you are looking for is:
Public Declare Function EnumJobs Lib "winspool.drv" Alias _
"EnumJobsA" (ByVal hPrinter As Long, ByVal FirstJob As Long, _
ByVal NoJobs As Long, ByVal Level As Long, pJob As Byte, ByVal _
cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long

This discussion is closed to new replies.