General discussion

Locked

control printer in a vb program

By yhham ·
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

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

control printer in a vb program

by shubens In reply to control printer in a vb p ...

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.

Collapse -

control printer in a vb program

by yhham In reply to control printer in a vb p ...

The question was auto-closed by TechRepublic

Collapse -

control printer in a vb program

by Czar Andy In reply to control printer in a vb p ...

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

Collapse -

control printer in a vb program

by yhham In reply to control printer in a vb p ...

The question was auto-closed by TechRepublic

Collapse -

control printer in a vb program

by yhham In reply to control printer in a vb p ...

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Software Forums