如何: 确定打印机状态和 $ 从 Visual Basic 的打印作业状态 使用类PrintJob进行打印操作时,应如何设置打印机名等打...

\u5982\u4f55\u83b7\u53d6\u6253\u5370\u673a\u548c\u6253\u5370\u4f5c\u4e1a\u7684\u72b6\u6001

\u5f00\u59cb--------\u6253\u5370\u673a\u548c\u4f20\u771f \u6216\u8005 \u63a7\u5236\u9762\u677f ----\u6253\u5370\u673a\u548c\u5176\u4ed6\u786c\u4ef6=---\u6253\u5370\u673a\u548c\u4f20\u771f
\u5c31\u80fd\u770b\u5230\u6253\u5370\u673a\u4e86

\u6211\u4eec\u5e38\u5e38\u4f7f\u7528\u6253\u5370\u673a\u6765\u6253\u5370\u7535\u8111\u91cc\u9762\u7684\u6570\u636e\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u4e0d\u540c\u7684\u8f6f\u4ef6\u90fd\u53ef\u4ee5\u8bbe\u7f6e\u6570\u636e\u6253\u5370\u7684\u7eb8\u5f20\u3001\u6a2a\u5411\u3001\u7eb5\u5411\u7b49\u7eb8\u5f20\u7684\u65b9\u5411\uff01
\u7136\u800c\uff0c\u5f53\u6211\u4eec\u4f7f\u7528\u6253\u5370\u673a\u6765\u6253\u5370\u7f51\u9875\u5185\u5bb9\u7684\u65f6\u5019\uff0c\u6d4f\u89c8\u5668\u7684\u6253\u5370\u8bbe\u7f6e\u96be\u4ee5\u4fdd\u5b58\uff0c\u52bf\u5fc5\u9020\u6210\u6bcf\u6253\u5370\u4e00\u6b21\u5c31\u5f97\u8bbe\u7f6e\u4e00\u6b21\u7684\u9ebb\u70e6\u3002



\u4e3a\u907f\u514d\u91cd\u590d\u8bbe\u7f6e\uff0c\u6240\u4ee5\u5c31\u9700\u8981\u7edf\u4e00\u4f7f\u7528\u540c\u79cd\u7eb8\u5f20\u3001\u6253\u5370\u65b9\u5411\u6765\u6253\u5370\u6570\u636e\uff0c\u6211\u4eec\u53ea\u9700\u8981\u7ed9\u6253\u5370\u673a\u8bbe\u7f6e\u9ed8\u8ba4\u7eb8\u5f20\u3001\u6253\u5370\u65b9\u5411\u5373\u53ef\u3002


01
\u901a\u8fc7\u83dc\u5355\u64cd\u4f5c\u6253\u5f00\u63a7\u5236\u9762\u677f\uff1a\u201c\u5f00\u59cb\u201d\u2192\u201c\u8bbe\u7f6e\u201d\u2192\u201c\u6253\u5370\u673a\u548c\u4f20\u771f\u201d\u3002


02\u53f3\u952e\u70b9\u51fb\u6253\u5370\u673a\u540d\u79f0\uff0c\u5728\u5f39\u51fa\u7684\u83dc\u5355\u4e2d\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002


03
\u5728\u201c\u5e38\u89c4\u201d\u9009\u9879\u5361\u4e0a\u70b9\u51fb\u201c\u6253\u5370\u9996\u9009\u9879\u201d\u3002



04
\u5207\u6362\u5230\u201c\u7eb8\u5f20/\u8d28\u91cf\u201d\u9009\u9879\u5361\uff0c\u5728\u8fd9\u91cc\uff0c\u5728\u201c\u5c3a\u5bf8\u4e3a\u201d\u7684\u4e0b\u9762\u53ef\u4ee5\u8bbe\u7f6e\u9ed8\u8ba4\u4f7f\u7528\u7684\u7eb8\u5f20\u3002\u7136\u540e\uff0c\u4f7f\u7528\u9f20\u6807\u5de6\u952e\u70b9\u51fb\u53f3\u8fb9\u7684\u9884\u89c8\u56fe\uff0c\u5982\u672c\u4f8b\u7684297\u00d7210\u6beb\u7c73\uff0c\u8fd9\u6837\u53ef\u4ee5\u9009\u62e9\u4e0d\u540c\u7684\u6253\u5370\u65b9\u5411\uff0c\u5373\u6a2a\u5411\u548c\u7eb5\u5411\u3002
\u6700\u540e\uff0c\u5207\u6362\u5230\u201c\u5b8c\u6210\u201d\u9009\u9879\u5361\u3002



05
\u70b9\u51fb\u201c\u5e94\u7528\u201d\u6309\u94ae\uff0c\u518d\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\uff0c\u521a\u624d\u7684\u8bbe\u7f6e\u5c31\u5e94\u7528\u5230\u6253\u5370\u673a\u7684\u6253\u5370\u5de5\u4f5c\u4e2d\u4e86\u3002\u6574\u4e2a\u64cd\u4f5c\u8fc7\u7a0b\u5b8c\u6210\u3002
\u5f53\u7136\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0a\u7684\u5404\u79cd\u9009\u9879\u5361\uff0c\u518d\u628a\u6253\u5370\u673a\u7684\u6253\u5370\u5c5e\u6027\uff0c\u8bbe\u7f6e\u5f97\u66f4\u590d\u6742\u4e9b\u3001\u66f4\u7b26\u5408\u60a8\u7684\u6253\u5370\u5de5\u4f5c\u3002

该技术的说明术语"打印机"可以指硬件设备、 队列、 一个的驱动程序或甚至一个端口。此本文"打印机"一词被指本地打印队列。这篇文章中的代码示例返回操作系统报告该状态。这是在同一状态打印后台处理程序所报告其中您可以检查通过观看本地打印队列。 例如对于在运行 Microsoft Windows 98 的计算机上查看队列,单击 开始、 指向 设置、 和单击 打印机,然后双击要查看的队列打印机的图标。 注意: 您不能直接与该物理打印机进行通信。您不必这样做是因为操作系统必须裁定对硬件的访问。 此示例报告状态从打印机和在的作业,但请注意该作业的状态信息是通常更可靠的应用程序。理想情况下,您单独,应检查该作业和打印机状态,代码应推断出该队列的"meta"状态。但是,对于大多数的使用您的代码都可以依赖作业状态。此外,本示例循环遍历该作业并检查并报告每个作业的状态。这是因为您的工作可能会按照报告问题,如超出纸张或 $ 获取堵塞的另一个作业。 注: 当系统有作业进行后台打印时,系统只检查状态。否则,队列将被视为"就绪"由于队列可以接受作业,即使硬件是处于错误状态。例如对于已打印的最后一个作业使用最后一张纸打印,如果操作系统不知道这之前,系统会尝试再次打印。 此外,尽管存在许多状态可能会报告的许多不支持的练习单元中。打印机硬件和端口监视器确定的状态报告。例如对于如果打印机缺纸和脱机,状态可能会报告为"打印"作业正试图做是因为。因此,队列,显示"就绪"并不保证您的打印作业将成功完成。 此代码示例检查仅在本地队列,对于大多数应用程序应该足够了。但是,连接到远程打印机可能会变得相当复杂。您可以链接在其中为本地队列端口是实际另一个队列的队列。您可以让打印机池,多个打印机从公共超级队列的工作。更复杂,体系结构时检索有意义的状态代码也变得更加复杂,而且将减少状态的用途。 在Microsoft Windows 95、 Microsoft Windows 98,和 Microsoft Windows Millennium 版仅,上,您还可以检查位 PRINTER_ATTRIBUTE_WORK_OFFLINE PrinterInfo.Attributes 字段。此状态是通常出现是由于用户操作 (例如对于如果用户右键单击打印机图标,然后再单击 脱机工作)。尽管操作系统可以强制状态,如果打印机不能连接到 despool 作业,这种状态不会由于在打印作业的状态更改的发生。在这种情况下通常是作为 USER_INERVENTION_REQUIRED 报告状态。 分步示例在Visual Basic 中创建一个新的标准 EXE 项目。默认状态下,创建 Form1。在项目 菜单上单击 添加模块,然后添加以下代码: Option Explicit Public Declare Function lstrcpy Lib "kernel32" _ Alias "lstrcpyA" _ (ByVal lpString1 As String, _ ByVal lpString2 As String) _ As Long Public Declare Function OpenPrinter Lib "winspool.drv" _ Alias "OpenPrinterA" _ (ByVal pPrinterName As String, _ phPrinter As Long, _ pDefault As PRINTER_DEFAULTS) _ As Long Public Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" _ (ByVal hPrinter As Long, _ ByVal Level As Long, _ pPrinter As Byte, _ ByVal cbBuf As Long, _ pcbNeeded As Long) _ As Long Public Declare Function ClosePrinter Lib "winspool.drv" _ (ByVal hPrinter As Long) _ As Long Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Any, _ Source As Any, _ ByVal Length As Long) 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 ' constants for PRINTER_DEFAULTS structure Public Const PRINTER_ACCESS_USE = &H8 Public Const PRINTER_ACCESS_ADMINISTER = &H4 ' constants for DEVMODE structure Public Const CCHDEVICENAME = 32 Public Const CCHFORMNAME = 32 Public Type PRINTER_DEFAULTS pDatatype As String pDevMode As Long DesiredAccess As Long End Type Public Type DEVMODE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmLogPixels As Integer dmBitsPerPel As Long dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Type JOB_INFO_2 JobId As Long pPrinterName As Long pMachineName As Long pUserName As Long pDocument As Long pNotifyName As Long pDatatype As Long pPrintProcessor As Long pParameters As Long pDriverName As Long pDevMode As Long pStatus As Long pSecurityDescriptor As Long Status As Long Priority As Long Position As Long StartTime As Long UntilTime As Long TotalPages As Long Size As Long Submitted As SYSTEMTIME time As Long PagesPrinted As Long End Type Type PRINTER_INFO_2 pServerName As Long pPrinterName As Long pShareName As Long pPortName As Long pDriverName As Long pComment As Long pLocation As Long pDevMode As Long pSepFile As Long pPrintProcessor As Long pDatatype As Long pParameters As Long pSecurityDescriptor As Long Attributes As Long Priority As Long DefaultPriority As Long StartTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As Long End Type Public Const ERROR_INSUFFICIENT_BUFFER = 122 Public Const PRINTER_STATUS_BUSY = &H200 Public Const PRINTER_STATUS_DOOR_OPEN = &H400000 Public Const PRINTER_STATUS_ERROR = &H2 Public Const PRINTER_STATUS_INITIALIZING = &H8000 Public Const PRINTER_STATUS_IO_ACTIVE = &H100 Public Const PRINTER_STATUS_MANUAL_FEED = &H20 Public Const PRINTER_STATUS_NO_TONER = &H40000 Public Const PRINTER_STATUS_NOT_AVAILABLE = &H1000 Public Const PRINTER_STATUS_OFFLINE = &H80 Public Const PRINTER_STATUS_OUT_OF_MEMORY = &H200000 Public Const PRINTER_STATUS_OUTPUT_BIN_FULL = &H800 Public Const PRINTER_STATUS_PAGE_PUNT = &H80000 Public Const PRINTER_STATUS_PAPER_JAM = &H8 Public Const PRINTER_STATUS_PAPER_OUT = &H10 Public Const PRINTER_STATUS_PAPER_PROBLEM = &H40 Public Const PRINTER_STATUS_PAUSED = &H1 Public Const PRINTER_STATUS_PENDING_DELETION = &H4 Public Const PRINTER_STATUS_PRINTING = &H400 Public Const PRINTER_STATUS_PROCESSING = &H4000 Public Const PRINTER_STATUS_TONER_LOW = &H20000 Public Const PRINTER_STATUS_USER_INTERVENTION = &H100000 Public Const PRINTER_STATUS_WAITING = &H2000 Public Const PRINTER_STATUS_WARMING_UP = &H10000 Public Const JOB_STATUS_PAUSED = &H1 Public Const JOB_STATUS_ERROR = &H2 Public Const JOB_STATUS_DELETING = &H4 Public Const JOB_STATUS_SPOOLING = &H8 Public Const JOB_STATUS_PRINTING = &H10 Public Const JOB_STATUS_OFFLINE = &H20 Public Const JOB_STATUS_PAPEROUT = &H40 Public Const JOB_STATUS_PRINTED = &H80 Public Const JOB_STATUS_DELETED = &H100 Public Const JOB_STATUS_BLOCKED_DEVQ = &H200 Public Const JOB_STATUS_USER_INTERVENTION = &H400 Public Const JOB_STATUS_RESTART = &H800 Public Function GetString(ByVal PtrStr As Long) As String Dim StrBuff As String * 256 'Check for zero address If PtrStr = 0 Then GetString = " " Exit Function End If 'Copy data from PtrStr to buffer. CopyMemory ByVal StrBuff, ByVal PtrStr, 256 'Strip any trailing nulls from string. GetString = StripNulls(StrBuff) End Function Public Function StripNulls(OriginalStr As String) As String 'Strip any trailing nulls from input string. If (InStr(OriginalStr, Chr(0)) > 0) Then OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1) End If 'Return modified string. StripNulls = OriginalStr End Function Public Function PtrCtoVbString(Add As Long) As String Dim sTemp As String * 512 Dim x As Long x = lstrcpy(sTemp, Add) If (InStr(1, sTemp, Chr(0)) = 0) Then PtrCtoVbString = "" Else PtrCtoVbString = Left(sTemp, InStr(1, sTemp, Chr(0)) - 1) End If End Function Public Function CheckPrinterStatus(PI2Status As Long) As String Dim tempStr As String If PI2Status = 0 Then ' Return "Ready" CheckPrinterStatus = "Printer Status = Ready" & vbCrLf Else tempStr = "" ' Clear If (PI2Status And PRINTER_STATUS_BUSY) Then tempStr = tempStr & "Busy " End If If (PI2Status And PRINTER_STATUS_DOOR_OPEN) Then tempStr = tempStr & "Printer Door Open " End If If (PI2Status And PRINTER_STATUS_ERROR) Then tempStr = tempStr & "Printer Error " End If If (PI2Status And PRINTER_STATUS_INITIALIZING) Then tempStr = tempStr & "Initializing " End If If (PI2Status And PRINTER_STATUS_IO_ACTIVE) Then tempStr = tempStr & "I/O Active " End If If (PI2Status And PRINTER_STATUS_MANUAL_FEED) Then tempStr = tempStr & "Manual Feed " End If If (PI2Status And PRINTER_STATUS_NO_TONER) Then tempStr = tempStr & "No Toner " End If If (PI2Status And PRINTER_STATUS_NOT_AVAILABLE) Then tempStr = tempStr & "Not Available " End If If (PI2Status And PRINTER_STATUS_OFFLINE) Then tempStr = tempStr & "Off Line " End If If (PI2Status And PRINTER_STATUS_OUT_OF_MEMORY) Then tempStr = tempStr & "Out of Memory " End If If (PI2Status And PRINTER_STATUS_OUTPUT_BIN_FULL) Then tempStr = tempStr & "Output Bin Full " End If If (PI2Status And PRINTER_STATUS_PAGE_PUNT) Then tempStr = tempStr & "Page Punt " End If If (PI2Status And PRINTER_STATUS_PAPER_JAM) Then tempStr = tempStr & "Paper Jam " End If If (PI2Status And PRINTER_STATUS_PAPER_OUT) Then tempStr = tempStr & "Paper Out " End If If (PI2Status And PRINTER_STATUS_OUTPUT_BIN_FULL) Then tempStr = tempStr & "Output Bin Full " End If If (PI2Status And PRINTER_STATUS_PAPER_PROBLEM) Then tempStr = tempStr & "Page Problem " End If If (PI2Status And PRINTER_STATUS_PAUSED) Then tempStr = tempStr & "Paused " End If If (PI2Status And PRINTER_STATUS_PENDING_DELETION) Then tempStr = tempStr & "Pending Deletion " End If If (PI2Status And PRINTER_STATUS_PRINTING) Then tempStr = tempStr & "Printing " End If If (PI2Status And PRINTER_STATUS_PROCESSING) Then tempStr = tempStr & "Processing " End If If (PI2Status And PRINTER_STATUS_TONER_LOW) Then tempStr = tempStr & "Toner Low " End If If (PI2Status And PRINTER_STATUS_USER_INTERVENTION) Then tempStr = tempStr & "User Intervention " End If If (PI2Status And PRINTER_STATUS_WAITING) Then tempStr = tempStr & "Waiting " End If If (PI2Status And PRINTER_STATUS_WARMING_UP) Then tempStr = tempStr & "Warming Up " End If 'Did you find a known status? If Len(tempStr) = 0 Then tempStr = "Unknown Status of " & PI2Status End If 'Return the Status CheckPrinterStatus = "Printer Status = " & tempStr & vbCrLf End If End Function 添加三个 命令按钮 控件。将三个 文本框 控件添加到 Form1,然后配置 TextBox 控件,如下所示:将每个 文本框 控件的 多行 属性设置为 True。调整到大约 5 英寸宽,三英寸长每个 文本框 的大小。将每个 文本框 控件的 滚动条 属性设置为 2-垂直。向Form1 中添加 Timer 控件。将下面的代码添加到窗体的模块: Option Explicit Private Sub Command1_Click() 'Enable the timer to begin printer status checks. Timer1.Enabled = True 'Enable and disable start and stop buttons. Command1.Enabled = False Command2.Enabled = True Command3.Enabled = True End Sub Private Sub Command2_Click() 'Disable timer to stop further printer checks. Timer1.Enabled = False 'Enable and disable start and stop buttons. Command1.Enabled = True Command2.Enabled = False Command3.Enabled = True End Sub Private Sub Command3_Click() 'Clear the status info. Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub Private Sub Form_Load() 'Initialize captions for control buttons. Command1.Caption = "Start" Command2.Caption = "Stop" Command3.Caption = "Clear" 'Clear the status info. Text1.Text = "" Text2.Text = "" Text3.Text = "" Command1.Enabled = True 'Disable stop and clear buttons. Command2.Enabled = False Command3.Enabled = False 'Set interval for printer status checking to 1/2 second. Timer1.Enabled = False Timer1.Interval = 500 End Sub Private Sub Timer1_Timer() Dim PrinterStatus As String Dim JobStatus As String Dim ErrorInfo As String 'Clear the status info for new info/status. Text1.Text = "" Text2.Text = "" Text3.Text = "" 'Call sub to perform check. Text1.Text = CheckPrinter(PrinterStatus, JobStatus) Text2.Text = PrinterStatus Text3.Text = JobStatus End Sub Public Function CheckPrinter(PrinterStr As String, JobStr As String) As String Dim hPrinter As Long Dim ByteBuf As Long Dim BytesNeeded As Long Dim PI2 As PRINTER_INFO_2 Dim JI2 As JOB_INFO_2 Dim PrinterInfo() As Byte Dim JobInfo() As Byte Dim result As Long Dim LastError As Long Dim PrinterName As String Dim tempStr As String Dim NumJI2 As Long Dim pDefaults As PRINTER_DEFAULTS Dim I As Integer 'Set a default return value if no errors occur. CheckPrinter = "Printer info retrieved" 'NOTE: You can pick a printer from the Printers Collection 'or use the EnumPrinters() API to select a printer name. 'Use the default printer of Printers collection. 'This is typically, but not always, the system default printer. PrinterName = Printer.DeviceName 'Set desired access security setting. pDefaults.DesiredAccess = PRINTER_ACCESS_USE 'Call API to get a handle to the printer. result = OpenPrinter(PrinterName, hPrinter, pDefaults) If result = 0 Then 'If an error occurred, display an error and exit sub. CheckPrinter = "Cannot open printer " & PrinterName & _ ", Error: " & Err.LastDllError Exit Function End If 'Init BytesNeeded BytesNeeded = 0 'Clear the error object of any errors. Err.Clear 'Determine the buffer size that is needed to get printer info. result = GetPrinter(hPrinter, 2, 0&, 0&, BytesNeeded) 'Check for error calling GetPrinter. If Err.LastDllError <> ERROR_INSUFFICIENT_BUFFER Then 'Display an error message, close printer, and exit sub. CheckPrinter = " > GetPrinter Failed on initial call! <" ClosePrinter hPrinter Exit Function End If 'Note that in Charles Petzold's book "Programming Windows 95," he 'states that because of a problem with GetPrinter on Windows 95 only, you 'must allocate a buffer as much as three times larger than the value 'returned by the initial call to GetPrinter. This is not done here. ReDim PrinterInfo(1 To BytesNeeded) ByteBuf = BytesNeeded 'Call GetPrinter to get the status. result = GetPrinter(hPrinter, 2, PrinterInfo(1), ByteBuf, _ BytesNeeded) 'Check for errors. If result = 0 Then 'Determine the error that occurred. LastError = Err.LastDllError() 'Display error message, close printer, and exit sub. CheckPrinter = "Couldn't get Printer Status! Error = " _ & LastError ClosePrinter hPrinter Exit Function End If 'Copy contents of printer status byte array into a 'PRINTER_INFO_2 structure to separate the individual elements. CopyMemory PI2, PrinterInfo(1), Len(PI2) 'Check if printer is in ready state. PrinterStr = CheckPrinterStatus(PI2.Status) 'Add printer name, driver, and port to list. PrinterStr = PrinterStr & "Printer Name = " & _ GetString(PI2.pPrinterName) & vbCrLf PrinterStr = PrinterStr & "Printer Driver Name = " & _ GetString(PI2.pDriverName) & vbCrLf PrinterStr = PrinterStr & "Printer Port Name = " & _ GetString(PI2.pPortName) & vbCrLf 'Call API to get size of buffer that is needed. result = EnumJobs(hPrinter, 0&, &HFFFFFFFF, 2, ByVal 0&, 0&, _ BytesNeeded, NumJI2) 'Check if there are no current jobs, and then display appropriate message. If BytesNeeded = 0 Then JobStr = "No Print Jobs!" Else 'Redim byte array to hold info about print job. ReDim JobInfo(0 To BytesNeeded) 'Call API to get print job info. result = EnumJobs(hPrinter, 0&, &HFFFFFFFF, 2, JobInfo(0), _ BytesNeeded, ByteBuf, NumJI2) 'Check for errors. If result = 0 Then 'Get and display error, close printer, and exit sub. LastError = Err.LastDllError CheckPrinter = " > EnumJobs Failed on second call! < Error = " _ & LastError ClosePrinter hPrinter Exit Function End If 'Copy contents of print job info byte array into a 'JOB_INFO_2 structure to separate the individual elements. For I = 0 To NumJI2 - 1 ' Loop through jobs and walk the buffer CopyMemory JI2, JobInfo(I * Len(JI2)), Len(JI2) ' List info available on Jobs. Debug.Print "Job ID" & vbTab & JI2.JobId Debug.Print "Name Of Printer" & vbTab & _ GetString(JI2.pPrinterName) Debug.Print "Name Of Machine That Created Job" & vbTab & _ GetString(JI2.pMachineName) Debug.Print "Print Job Owner's Name" & vbTab & _ GetString(JI2.pUserName) Debug.Print "Name Of Document" & vbTab & GetString(JI2.pDocument) Debug.Print "Name Of User To Notify" & vbTab & _ GetString(JI2.pNotifyName) Debug.Print "Type Of Data" & vbTab & GetString(JI2.pDatatype) Debug.Print "Print Processor" & vbTab & _ GetString(JI2.pPrintProcessor) Debug.Print "Print Processor Parameters" & vbTab & _ GetString(JI2.pParameters) Debug.Print "Print Driver Name" & vbTab & _ GetString(JI2.pDriverName) Debug.Print "Print Job 'P' Status" & vbTab & _ GetString(JI2.pStatus) Debug.Print "Print Job Status" & vbTab & JI2.Status Debug.Print "Print Job Priority" & vbTab & JI2.Priority Debug.Print "Position in Queue" & vbTab & JI2.Position Debug.Print "Earliest Time Job Can Be Printed" & vbTab & _ JI2.StartTime Debug.Print "Latest Time Job Will Be Printed" & vbTab & _ JI2.UntilTime Debug.Print "Total Pages For Entire Job" & vbTab & JI2.TotalPages Debug.Print "Size of Job In Bytes" & vbTab & JI2.Size 'Because of a bug in Windows NT 3.51, the time member is not set correctly. 'Therefore, do not use the time member on Windows NT 3.51. Debug.Print "Elapsed Print Time" & vbTab & JI2.time Debug.Print "Pages Printed So Far" & vbTab & JI2.PagesPrinted 'Display basic job status info. JobStr = JobStr & "Job ID = " & JI2.JobId & _ vbCrLf & "Total Pages = " & JI2.TotalPages & vbCrLf tempStr = "" 'Clear 'Check for a ready state. If JI2.pStatus = 0& Then ' If pStatus is Null, check Status. If JI2.Status = 0 Then tempStr = tempStr & "Ready! " & vbCrLf Else 'Check for the various print job states. If (JI2.Status And JOB_STATUS_SPOOLING) Then tempStr = tempStr & "Spooling " End If If (JI2.Status And JOB_STATUS_OFFLINE) Then tempStr = tempStr & "Off line " End If If (JI2.Status And JOB_STATUS_PAUSED) Then tempStr = tempStr & "Paused " End If If (JI2.Status And JOB_STATUS_ERROR) Then tempStr = tempStr & "Error " End If If (JI2.Status And JOB_STATUS_PAPEROUT) Then tempStr = tempStr & "Paper Out " End If If (JI2.Status And JOB_STATUS_PRINTING) Then tempStr = tempStr & "Printing " End If If (JI2.Status And JOB_STATUS_USER_INTERVENTION) Then tempStr = tempStr & "User Intervention Needed " End If If Len(tempStr) = 0 Then tempStr = "Unknown Status of " & JI2.Status End If End If Else ' Dereference pStatus. tempStr = PtrCtoVbString(JI2.pStatus) End If 'Report the Job status. JobStr = JobStr & tempStr & vbCrLf Debug.Print JobStr & tempStr Next I End If 'Close the printer handle. ClosePrinter hPrinter End Function 请转到您的打印队列,然后暂停该打印机。请注意您可能需要一个本地打印机,而不是要暂停打印队列的网络打印机。运行示例的项目,然后单击 开始。从另一个应用程序,如记事本) 执行一个或多个打印操作。在文本框中显示打印机信息。请注意作业详细信息显示在立即窗口中。如有必要,单击滚动文字框和立即窗口可以查看此打印机的信息窗体上的 停止。故障排除仅特定设备驱动程序可以获得实时、 准确的打印机的状态信息。此代码将获取相同的状态报告的 Windows 后台处理程序。回到顶端 | 提供反馈

扩展阅读:打印机一直噔噔噔的响 ... 手机直连打印机的方法 ... 惠普打印机与手机直连 ... 打印机不进纸维修视频 ... 惠普打印机状态错误 ... 打印机转动有嘎嘎异响 ... 爱普生打印机 set jig ... 打印不清晰处理方法 ... 手机直接连接打印机步骤 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网