|
-
Oct 3rd, 2000, 10:47 PM
#1
Thread Starter
Member
With two print jobs queued, the first Win32 API call to EnumJobs, shown below,
retval = EnumJobs(hPrinter, 0, 100, 2, ByVal 0, 0, needed, numitems)
returns retval = 1 and needed = numitems = 0. It should have returned retval = 0, numitems = 2, and needed = a non-zero number of bytes needed in the byte buffer to be filled with Job_Info_2 data during the second call to EnumJobs. What gives? I’m running vanilla VB 6 SP4 on Windows 95 and have a single printer, an Epson Color Stylus 600. The api calls correctly identify the name of my printer, and the hwnd value returned for the printer (hPrinter = 5308460) appears to be correct.
I’m also experiencing a similar problem with GetPrinter, for which I am never able to get a cJobs return value of anything other than zero.
John Fritch
-
Oct 6th, 2000, 02:19 PM
#2
I just tried this function, and it returns the number of printjobs in my printers queue. However, I don't really see an error in your code, providing that the line of code you supplied it supposed to return the error (0) and the buffersize needed.
Code:
Private Function EnumPrintJobs(ByVal hPrinter As Long) As Long
Dim retVal As Long
Dim BufNeeded As Long
Dim Returned As Long
Dim Buffer() As Byte
' we expect an error here if there are jobs in the queue,
' but we need to know the buffersize needed
retVal = EnumJobs(hPrinter, 0, &HFFFFFFFF, 1, 0, 0, BufNeeded, Returned)
If retVal = 0 Then
If Err.LastDllError = ERROR_INSUFFICIENT_BUFFER Then
ReDim Buffer(BufNeeded)
retVal = EnumJobs(hPrinter, 0, &HFFFFFFFF, 1, Buffer(0), BufNeeded, BufNeeded, Returned)
EnumPrintJobs = Returned
Else
MsgBox "There is an error getting Printerinformation"
EnumPrintJobs = 0
End If
Else
EnumPrintJobs = 0
End If
End Function
-
Oct 6th, 2000, 03:22 PM
#3
Thread Starter
Member
Frans,
Thanks for the reply. I have a follow-up thread, "Can Printer Software Usurp EnumJobs and GetPrinter?" which you might want to check out.
John Fritch
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|