Results 1 to 4 of 4

Thread: Print multiple files w/1 print job

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2002
    Posts
    80

    Print multiple files w/1 print job

    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

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    JOB_INFO_3 is only supported in Windows NT4 or beyond.

    From the EventVB code::

    VB Code:
    1. Public Enum PrintJobStatuses
    2.     JOB_STATUS_PAUSED = &H1
    3.     JOB_STATUS_ERROR = &H2
    4.     JOB_STATUS_DELETING = &H4
    5.     JOB_STATUS_SPOOLING = &H8
    6.     JOB_STATUS_PRINTING = &H10
    7.     JOB_STATUS_OFFLINE = &H20
    8.     JOB_STATUS_PAPEROUT = &H40
    9.     JOB_STATUS_PRINTER = &H80
    10.     JOB_STATUS_DELETED = &H100
    11.     JOB_STATUS_BLOCKED_DEVICEQUEUE = &H200
    12.     JOB_STATUS_USER_INTERVENTION = &H400
    13.     JOB_STATUS_RESTART = &H800
    14. End Enum
    15.  
    16. '\\ Included in WINNT4 and beyond
    17. Private Type JOB_INFO_3
    18.     JobId As Long
    19.     NextJobId As Long
    20.     Reserved As Long 'must be set to zero
    21. End Type
    22.  
    23. Private Declare Function GetJob Lib "winspool.drv" Alias "GetJobA" _
    24.                           (ByVal hPrinter As Long, _
    25.                            ByVal JobId As Long, _
    26.                            ByVal Level As Long, _
    27.                            buffer As Long, _
    28.                            ByVal pbSize As Long, _
    29.                            pbSizeNeeded As Long) As Long
    30.  
    31. Private Declare Function SetJob Lib "winspool.drv" Alias _
    32.                      "SetJobA" (ByVal hPrinter As Long, _
    33.                                 ByVal JobId As Long, _
    34.                                 ByVal Level As Long, _
    35.                                 pJob As Long, _
    36.                                 ByVal Command As Long) As Long
    37.  
    38.  
    39. '\\ Private member variables
    40. Private mJobId As Long 'Unique id of this job
    41. Private mhPrinter As Long 'Printer this job is on...
    42.  
    43. Private mJOB_INFO_1 As JOB_INFO_1
    44. Private mJOB_INFO_2 As JOB_INFO_2
    45. Private mJOB_INFO_3 As JOB_INFO_3
    46.  
    47. '\\ Private variable to prevent unneccessary calls to the dll...
    48. Private mLastApiCall(1 To 3) As Date
    49.  
    50. Private bChanged As Boolean
    51.  
    52. Public Enum PrintJobControlCommands
    53.      JOB_CONTROL_PAUSE = 1
    54.      JOB_CONTROL_RESUME = 2
    55.      JOB_CONTROL_CANCEL = 3
    56.      JOB_CONTROL_RESTART = 4
    57.      JOB_CONTROL_DELETE = 5
    58.      JOB_CONTROL_SENT_TO_PRINTER = 6
    59.      JOB_CONTROL_LAST_PAGE_EJECTED = 7
    60. End Enum
    61.  
    62. '\\ When changing information other than the position for JOB_INFO_1 and
    63. '\\ JOB_INFO_2 you must set the Position member to JOB_POSITION_UNSPECIFIED
    64. Private Const JOB_POSITION_UNSPECIFIED = 0
    65.  
    66. Private buffer() As Long
    67.  
    68. Friend Property Let JobId(ByVal newJobId As Long)
    69.  
    70.     mJobId = newJobId
    71.  
    72. End Property
    73.  
    74. Public Property Get JobId() As Long
    75.  
    76.     JobId = mJobId
    77.  
    78. End Property
    79.  
    80. Public Sub LinkToJob(ByVal newJob As ApiPrintJob)
    81.  
    82. If newJob.JobId <> JobId Then
    83.     With mJOB_INFO_3
    84.         .JobId = JobId
    85.         .NextJobId = newJob.JobId
    86.         .Reserved = 0
    87.     End With
    88.     Call SavePrintJobInfo(3)
    89. End If
    90.  
    91. End Sub
    92.  
    93.  
    94. Private Sub RefreshJobInfo(ByVal Index As Integer)
    95.  
    96. Dim lret As Long
    97. Dim SizeNeeded As Long
    98.  
    99. '\\ Prevent unneccesary call to the API
    100. If DateDiff("s", mLastApiCall(Index), Now) > 1 Then
    101.     mLastApiCall(Index) = Now
    102.  
    103.     ReDim Preserve buffer(0 To 1) As Long
    104.     lret = GetJob(mhPrinter, mJobId, Index, buffer(0), UBound(buffer), SizeNeeded)
    105.  
    106.     If SizeNeeded > 0 Then
    107.         ReDim Preserve buffer(0 To (SizeNeeded / 4) + 3) As Long
    108.         lret = GetJob(mhPrinter, mJobId, Index, buffer(0), UBound(buffer) * 4, SizeNeeded)
    109.  
    110.         If Index < 1 Or Index > 3 Then
    111.             Debug.Print "Error in call to ApiPrintJob:RefreshJobInfo - invalid index"
    112.         Else
    113.             Select Case Index
    114.             Case 3
    115.                 With mJOB_INFO_3
    116.                     .JobId = buffer(0)
    117.                     .NextJobId = buffer(1)
    118.                     .Reserved = buffer(2)
    119.                 End With
    120.             End Select
    121.         End If
    122.     End If
    123. End If
    124.  
    125. End Sub
    126.  
    127. Private Sub SavePrintJobInfo(ByVal Level As Long)
    128.  
    129. Dim lret As Long
    130.  
    131. Select Case Level
    132. Case 3
    133.     '\\ Overwrite existing buffer data with that held locally in JOB_INFO_3
    134.     With mJOB_INFO_3
    135.         buffer(0) = .JobId
    136.         buffer(1) = .NextJobId
    137.         buffer(2) = .Reserved
    138.     End With
    139.  
    140. End Select

  3. #3

    Thread Starter
    Registered User
    Join Date
    Jul 2002
    Posts
    80
    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.

  4. #4
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    Everything else was carved from the ApiPrintJob class....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width