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 Any, _ ByVal cdBuf As Long, _ pcbNeeded As Long, _ pcReturned As Long) As Long
EnumJobs перечисляет задания, находящиеся в очереди печати.
Dim hPrinter As Long, lNeeded As Long, lReturned As Long Dim lJobCount As Long OpenPrinter Printer.DeviceName, hPrinter, ByVal 0& EnumJobs hPrinter, 0, 99, 1, ByVal 0&, 0, lNeeded, lReturned If lNeeded > 0 Then ReDim byteJobsBuffer(lNeeded - 1) As Byte EnumJobs hPrinter, 0, 99, 1, byteJobsBuffer(0), lNeeded, lNeeded, lReturned If lReturned > 0 Then lJobCount = lReturned Else lJobCount = 0 End If Else lJobCount = 0 End If ClosePrinter hPrinter MsgBox "Jobs in printer queue: " + CStr(lJobCount), vbInformation