I'm not sure how to use the JOB_INFO_3 to print batch files. Can someone give an example how I can print multiple files in one print job using the SetJob API with JOB_INFO_3?
Thank you,
James
Printable View
I'm not sure how to use the JOB_INFO_3 to print batch files. Can someone give an example how I can print multiple files in one print job using the SetJob API with JOB_INFO_3?
Thank you,
James
JOB_INFO_3 is only supported in Windows NT4 or beyond.
From the EventVB code::
VB Code:
Public Enum PrintJobStatuses JOB_STATUS_PAUSED = &H1 JOB_STATUS_ERROR = &H2 JOB_STATUS_DELETING = &H4 JOB_STATUS_SPOOLING = &H8 JOB_STATUS_PRINTING = &H10 JOB_STATUS_OFFLINE = &H20 JOB_STATUS_PAPEROUT = &H40 JOB_STATUS_PRINTER = &H80 JOB_STATUS_DELETED = &H100 JOB_STATUS_BLOCKED_DEVICEQUEUE = &H200 JOB_STATUS_USER_INTERVENTION = &H400 JOB_STATUS_RESTART = &H800 End Enum '\\ Included in WINNT4 and beyond Private Type JOB_INFO_3 JobId As Long NextJobId As Long Reserved As Long 'must be set to zero End Type Private Declare Function GetJob Lib "winspool.drv" Alias "GetJobA" _ (ByVal hPrinter As Long, _ ByVal JobId As Long, _ ByVal Level As Long, _ buffer As Long, _ ByVal pbSize As Long, _ pbSizeNeeded As Long) As Long Private Declare Function SetJob Lib "winspool.drv" Alias _ "SetJobA" (ByVal hPrinter As Long, _ ByVal JobId As Long, _ ByVal Level As Long, _ pJob As Long, _ ByVal Command As Long) As Long '\\ Private member variables Private mJobId As Long 'Unique id of this job Private mhPrinter As Long 'Printer this job is on... Private mJOB_INFO_1 As JOB_INFO_1 Private mJOB_INFO_2 As JOB_INFO_2 Private mJOB_INFO_3 As JOB_INFO_3 '\\ Private variable to prevent unneccessary calls to the dll... Private mLastApiCall(1 To 3) As Date Private bChanged As Boolean Public Enum PrintJobControlCommands JOB_CONTROL_PAUSE = 1 JOB_CONTROL_RESUME = 2 JOB_CONTROL_CANCEL = 3 JOB_CONTROL_RESTART = 4 JOB_CONTROL_DELETE = 5 JOB_CONTROL_SENT_TO_PRINTER = 6 JOB_CONTROL_LAST_PAGE_EJECTED = 7 End Enum '\\ When changing information other than the position for JOB_INFO_1 and '\\ JOB_INFO_2 you must set the Position member to JOB_POSITION_UNSPECIFIED Private Const JOB_POSITION_UNSPECIFIED = 0 Private buffer() As Long Friend Property Let JobId(ByVal newJobId As Long) mJobId = newJobId End Property Public Property Get JobId() As Long JobId = mJobId End Property Public Sub LinkToJob(ByVal newJob As ApiPrintJob) If newJob.JobId <> JobId Then With mJOB_INFO_3 .JobId = JobId .NextJobId = newJob.JobId .Reserved = 0 End With Call SavePrintJobInfo(3) End If End Sub Private Sub RefreshJobInfo(ByVal Index As Integer) Dim lret As Long Dim SizeNeeded As Long '\\ Prevent unneccesary call to the API If DateDiff("s", mLastApiCall(Index), Now) > 1 Then mLastApiCall(Index) = Now ReDim Preserve buffer(0 To 1) As Long lret = GetJob(mhPrinter, mJobId, Index, buffer(0), UBound(buffer), SizeNeeded) If SizeNeeded > 0 Then ReDim Preserve buffer(0 To (SizeNeeded / 4) + 3) As Long lret = GetJob(mhPrinter, mJobId, Index, buffer(0), UBound(buffer) * 4, SizeNeeded) If Index < 1 Or Index > 3 Then Debug.Print "Error in call to ApiPrintJob:RefreshJobInfo - invalid index" Else Select Case Index Case 3 With mJOB_INFO_3 .JobId = buffer(0) .NextJobId = buffer(1) .Reserved = buffer(2) End With End Select End If End If End If End Sub Private Sub SavePrintJobInfo(ByVal Level As Long) Dim lret As Long Select Case Level Case 3 '\\ Overwrite existing buffer data with that held locally in JOB_INFO_3 With mJOB_INFO_3 buffer(0) = .JobId buffer(1) = .NextJobId buffer(2) = .Reserved End With End Select
Merrion,
I'm not sure where to place the functions and subprocedures. I know where to declare the API calls but I don't know where everything else goes. Please help.
Everything else was carved from the ApiPrintJob class....