检测打印机状态(VB实现)

VB.Net集成BarTender实现自动化标签打印的实战指南 本文提供了一份详细的VB.Net集成BarTender实现自动化标签打印的实战指南。通过环境搭建、代码示例与进阶技巧,系统讲解了如何利用VB.Net程序驱动BarTender,高效处理批量、可变数据的标签打印任务,适用于仓库管理、生产线追踪等业务场景,有效提升工作效率与准确性。 阅读详情

       没有时间翻译,各位见谅啊?代码很简单,注意API的使用!

Check this out... I found this while surfing internet from Spanish site

1. Start a new project in Visual Basic. Form1 is created by default.


2. Add two CommandButtons, two ListBoxes and a Timer control to Form1.


3. Paste the following code into the Form's module:


   Option Explicit


   Private Sub Command1_Click()
      'Enable the timer to begin printer status checks
      Timer1.Enabled = True


      'Enable/disable start/stop buttons
      Command1.Enabled = False
      Command2.Enabled = True
   End Sub


   Private Sub Command2_Click()
      'Clear the lists
      List1.Clear
      List2.Clear


      'Disable timer to stop further printer checks
      Timer1.Enabled = False


      'Enable/disable start/stop buttons
      Command1.Enabled = True
      Command2.Enabled = False
   End Sub


   Private Sub Form_Load()
      'Initialize captions for control buttons
      Command1.Caption = "Start"
      Command2.Caption = "Stop"


      'Disable stop button
      Command2.Enabled = False


      'Set interval for printer status checking to 1/2 second
      Timer1.Enabled = False
      Timer1.Interval = 500
   End Sub


   Private Sub Timer1_Timer()
      'Call sub to perform check
      CheckPrinter
   End Sub


   Private Sub CheckPrinter()
      Dim hPrinter As Long
      Dim ByteBuf As Long, 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, LastError As Long
      Dim PrinterName As String, tempStr As String
      Dim NumJI2 As Long
      Dim pDefaults As PRINTER_DEFAULTS


      'Clear the lists for new info/status
      List1.Clear
      List2.Clear


      '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
      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 occured, display an error and exit sub
         MsgBox "Cannot open printer " & PrinterName & ", Error: " _
           & Err.LastDllError
         Exit Sub
      End If


      'Init BytesNeeded
      BytesNeeded = 0


      'Clear the error object of any errors
      Err.Clear


      'Determine the buffer size 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
         List1.AddItem " > GetPrinter Failed on initial call! <"
         ClosePrinter hPrinter
         Exit Sub
      End If


      'Due to a problem with GetPrinter, we must allocate a buffer as
      'much as 3 times larger than the value returned by the initial
      'call to GetPrinter.  See page 790 of Charles Petzold's book
      '"Programming Windows 95" for additional information
      ReDim PrinterInfo(1 To BytesNeeded * 3)


      ByteBuf = BytesNeeded


      'Call GetPrinter to get the status
      result = GetPrinter(hPrinter, 2, PrinterInfo(1), ByteBuf, _
        BytesNeeded * 3)


      'Check for errors
      If result = 0 Then
         'Determine the error that occured
         LastError = Err.LastDllError()


         'Display error message, close printer, and exit sub
         List1.AddItem "Couldn't get Printer Status!"
         List1.AddItem "... Error = " & LastError
         ClosePrinter hPrinter
         Exit Sub
      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
      If PI2.Status = 0 Then
         List1.AddItem "Printer Status = Ready"
      Else
         List1.AddItem "Printer Status = " & PI2.Status
      End If


      'Add printer name, driver, and port to list
      List1.AddItem "Printer Name = " & GetString(PI2.pPrinterName)
      List1.AddItem "Printer Driver Name = " & GetString(PI2.pDriverName)
      List1.AddItem "Printer Port Name = " & GetString(PI2.pPortName)


      'Call API to get size of buffer needed
      result = EnumJobs(hPrinter, 0&, 1, 2, 0&, 0&, BytesNeeded, NumJI2)


      'Check if there are no current jobs and display appropriate message
      If BytesNeeded = 0 Then
         List2.AddItem "No Print Jobs!"
      Else
         'Redim byte array to hold info about print job
         ReDim JobInfo(1 To BytesNeeded * 3)


         'Call API to get print job info
         result = EnumJobs(hPrinter, 0&, 1, 2, JobInfo(1), _
           BytesNeeded * 3, ByteBuf, NumJI2)


         'Check for errors
         If result = 0 Then
            'Get and display error, close printer, and exit sub
            LastError = Err.LastDllError
            List2.AddItem " > EnumJobs Failed on second call! <"
            List2.AddItem "... Error = " & LastError
            ClosePrinter hPrinter
            Exit Sub
         End If


         'Copy contents of print job info byte array into a
         'JOB_INFO_2 structure to separate the individual elements
         CopyMemory JI2, JobInfo(1), Len(JI2)


         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
         'Due to a bug since NT 3.51, the time member is not set correctly
         'so don't use it.
         Debug.Print "Elapsed Print Time" & vbTab & JI2.time
         Debug.Print "Pages Printed So Far" & vbTab & JI2.PagesPrinted


         'Display basic job status info
         List2.AddItem "Job ID = " & JI2.JobId
         List2.AddItem "Total Pages = " & JI2.TotalPages


         'Check for a ready state
         If JI2.Status = 0 Then
            tempStr = tempStr & "Ready!  "
         Else  'Check for the various print job states
            If (JI2.Status And JOB_STATUS_SPOOLING) > 0 Then
               tempStr = tempStr & "Spooling  "
            End If


            If (JI2.Status And JOB_STATUS_OFFLINE) > 0 Then
               tempStr = tempStr & "Off line  "
            End If


            If (JI2.Status And JOB_STATUS_PAUSED) > 0 Then
               tempStr = tempStr & "Paused  "
            End If


            If (JI2.Status And JOB_STATUS_ERROR) > 0 Then
               tempStr = tempStr & "Error  "
            End If


            If (JI2.Status And JOB_STATUS_PAPEROUT) > 0 Then
               tempStr = tempStr & "Paper Out  "
            End If


            If (JI2.Status And JOB_STATUS_PRINTING) > 0 Then
               tempStr = tempStr & "Printing  "
            End If


            If (JI2.Status And JOB_STATUS_USER_INTERVENTION) > 0 Then
               tempStr = tempStr & "User Intervention Needed  "
            End If


            If Len(tempStr) = 0 Then
               tempStr = "Unknown Status of " & JI2.Status
            End If
         End If


         'Display the status
         List2.AddItem tempStr
         Debug.Print tempStr
      End If


      'Close the printer handle
      ClosePrinter hPrinter
   End Sub


4. From the Project menu add a new Module and paste in the following code:


   Option Explicit


   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, 64


      'Strp any trailing nulls from sting
      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

thanks
bhaspup
 
Comment from charlotte_keane
Date: 12/21/2005 11:19PM PST
 Author Comment 


DeadlyTrev

how do i put this code in vb

HKEY_CURRENT_CONFIG/System/CurrentControlSet/Control/Print/Printers/<printer_name>
      PrinterOnline DWORD


bhaspup

i tried your code but it does not get the correct status
 
Comment from DeadlyTrev
Date: 12/22/2005 04:08PM PST
 Comment 


'You need some registry reading/writing routines;
'The code below handles all the everyday aspects of registry I/O for VB6
'You just need the QueryValue Function
'
'    Dim rtn as long
'    Dim pstatus as  long
'    rtn = QueryValue(HKEY_CURRENT_CONFIG, "System/CurrentControlSet/Control/Print/Printers/<printer_name>", "PrinterOnline", pstatus)

Public Const REG_SZ = 1
Public Const REG_DWORD = 4
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const KEY_ALL_ACCESS = &H3F
Public Const ERROR_NONE = 0
Public Const REG_OPTION_NON_VOLATILE = 0

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long

Public Function QueryValue(hKey As Long, sKeyName As String, sValueName As String, vValue As Variant) As Long

    Dim lRetVal As Long         'result of the API functions
         
    lRetVal = RegOpenKeyEx(hKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    If (lRetVal <> 0) Then GoTo leave
    lRetVal = QueryValueEx(hKey, sValueName, vValue)
    If (lRetVal <> 0) Then GoTo leave
    RegCloseKey (hKey)
leave:
    QueryValue = lRetVal

End Function

Public Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long
   
    Dim cch As Long
    Dim lrc As Long
    Dim lType As Long
    Dim lValue As Long
    Dim sValue As String

    On Error GoTo QueryValueExError

    ' Determine the size and type of data to be read
    lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
    If lrc <> ERROR_NONE Then Error 5
    Select Case lType
        ' For strings
        Case REG_SZ:
            sValue = String$(cch, 0)
            lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch)
            If lrc = ERROR_NONE Then
                vValue = Left$(sValue, cch - 1)
            Else
                vValue = vbNullString
            End If
        ' For DWORDS
        Case REG_DWORD:
            lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch)
            If lrc = ERROR_NONE Then vValue = lValue
        Case Else
            'all other data types not supported
            lrc = -1
            vValue = Empty
    End Select

QueryValueExExit:
    QueryValueEx = lrc
    Exit Function

QueryValueExError:
    Resume QueryValueExExit

End Function

Public Function SetKeyValue(hKey As Long, sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long) As Long
   
    Dim lRetVal As Long      'result of the SetValueEx function
    Dim tmpkey As Long
   
    tmpkey = hKey
    'open the specified key
    lRetVal = RegOpenKeyEx(hKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    If lRetVal = 2 Then
          lRetVal = CreateNewKey(sKeyName, tmpkey)
          hKey = tmpkey
          lRetVal = RegOpenKeyEx(hKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    End If
    If (lRetVal <> 0) Then GoTo leave
    lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
    If (lRetVal <> 0) Then GoTo leave
    RegCloseKey (hKey)
leave:
    SetKeyValue = lRetVal

End Function

Private Function CreateNewKey(sNewKeyName As String, lPredefinedKey As Long) As Long

    Dim hNewKey As Long         'handle to the new key
    Dim lRetVal As Long         'result of the RegCreateKeyEx function

    lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
    If lRetVal = 0 Then RegCloseKey (hNewKey)
    CreateNewKey = lRetVal

End Function

Private Function SetValueEx(ByVal hKey As Long, sValueName As String, lType As Long, vValue As Variant) As Long
   
    Dim lValue As Long
    Dim sValue As String
   
    Select Case lType
        Case REG_SZ
            sValue = vValue & Chr$(0)
            SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, sValue, Len(sValue))
        Case REG_DWORD
            lValue = vValue
            SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, lType, lValue, 4)
        End Select

End Function

 
Comment from charlotte_keane
Date: 12/23/2005 12:57AM PST
 Author Comment 

VB中检测系统打印机安装状态的两种方法 EnumPrinters函数是Windows API提供的一个用于枚举系统中安装的打印机的函数。通过它,开发者可以获取到系统中所有打印机的详细列表,并且可以访问到打印机的名称、位置、注释以及打印驱动程序等相关信息。这在开发涉及到打印功能的应用时非常有用,尤其是需要对打印机进行管理和配置的应用。 阅读详情

相关推荐

VB源码实现打印机任务监控系统

在当今信息化时代,打印机任务监控系统对于企业办公自动化和高效管理起到了至关重要的作用。本章节旨在为读者概述VB(Visual Basic)源码打印机任务监控系统的核心理念、必要性以及基本功能。随着网络技术的普及,打印机不再局限于单机使用,网络打印机的广泛部署需要更加智能的任务监控与管理工具。VB作为一种简单易学的编程语言,在开发这类监控工具时表现出色,具有良好的扩展性和可视化开发环境。

weixin_35950531的博客 727

vb.net中如何检测打印机

vb.net中如何检测打印机 请问在vb.net中如何检测打印机是否安装或是否激活? ------解决方案-------------------- if (System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count { MessageBox.Show( "没找到打印机 "); } ------解决方案

cdz1022的专栏 2527

VB编程实现USB通信实例解析

在更复杂的系统中,驱动程序可以实现自定义的事件处理逻辑,例如更新设备状态、调整系统资源分配或者记录事件日志等。

weixin_32456485的博客 451

VB 获取默认打印机的状态

如何获取默认打印机的状态,包括缺纸、卡纸、无连接等状态,还有将某文件打印后,如何得知打印成功?Option ExplicitDeclare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As LongDeclare F...

demonzsmj12315的博客 733

VBA 获取打印机状态

vba 通过WMI服务,查找本机所有打印服务,通过打印机名称历遍所有打印机实施状态,如等待中.打印中等

VB6.0设计条形码打印程序

摘要:VB源码,报表打印,条形码打印  VB6.0源码设计的条形码打印程序,输入条形码,单击窗体即可启动打印程序,程序会自动检测打印机并执行打印功能。

VB怎么检测打印机状态

http://topic.youkuaiyun.com/t/20050819/16/4219161.html VB code Option Explicit Declare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As ...

weixin_30287169的博客 582

excel vba中设置打印机的代码

在excel中通过注册表获得所有系统打印机,并根据需要指定其一的代码。

用C#检测你的打印机是否连接

点击此处下载全部源程序 【下载说明】 1、单击上面这个地址,打开下载页面。 2、点普通下载--等待30秒--点“下载”按钮--保存 介绍 下面的代码将会检测你的系统是否已经连接到一个打印机。通过USB和网络连接的打印机都是可以被检测到的(尚未测试LPT口的打印机)。 一些打印机(如我的HP DeskJet 930c)尽管我按了OFF按钮(只有电源适配器是开着的),仍

apk508 9617

VB 开发的打印任务监控程序,源码开源下载.rar

VB 开发的打印任务监控程序,源码开源下载,适时获得当前打印机的任务状态,列出正在打印的任务,同时对所有任务进行管理 ,可结束和暂停任务,写的不错。

Python 上位机开发

首先,什么是上位机?上位机通常是指可以与下位机(如单片机、传感器等硬件设备)进行通信和交互,实现数据采集、控制指令发送以及数据处理和展示的计算机程序。 Python 作为一种高级编程语言,在开发上位机方面具有诸多优势。它拥有丰富的第三方库,使得开发过程变得相对简单和高效。

weixin_46807151的博客 4303

VB 通过MSComm控件取得打印机的状态:正常、缺纸、卡纸等

此方法使用VB中的串口通信控件MSComm给打印机发送指令,然后打印机自动返回其状态值,根据不同的返回值就可以判断打印机是正常、缺纸、卡纸等状态。其中的指令适用于Star SP500系列。注意在使用此方法时不要安装打印机的驱动,或者在驱动中设置的串口端口与此程序中的要不能相同,否则程序会提示参数设置错误,其实就是端口已经被占用的原因。 Option ExplicitDim Status A

海纳百川@一亩三分地 4576

FFmpeg视频缩放终极指南:从基础命令到保持宽高比的5种实战技巧

本文是FFmpeg视频缩放的终极指南,详细讲解了从基础命令到保持宽高比的5种实战技巧。针对不同平台(如抖音、B站、Instagram)的分辨率要求,提供了具体的参数模板和批量处理脚本,帮助内容创作者高效、精准地调整视频大小,避免画面变形或黑边问题,实现多平台适配。

juice的博客 462

vb 如何检测打印机是否联机_怎么检测网络打印机是否与电脑连接成功【检测方法】...

  想必不少宝宝和以前的小编一样,在用网络打印机的时候,有时候能打印,有时候却打印不了。那么如何 检测网络打印机是否与电脑连接成功?跟随小编往下看。  系统反反复复告知“无法打印”,让工作本已繁忙的小修近乎奔溃! 那么,如何检测 打印机跟电脑是否已经连接了,以避免这样让人束手无措的情况发生呢?  小编经过维修达人的层层点拨,已经将难题迎刃而解了! 在这里,为大家梳理了两种搞定问题的方式。  第一种...

weixin_39523887的博客 528

从指令到坐标:深度解析307系列基站定位的AT指令实战与排错

本文深度解析了ML307系列模组基站定位的AT指令实战应用与排错方法。重点剖析了AT+MLBSCFG和AT+MLBSLOC两条核心指令的配置、执行流程及异步响应机制,并针对高德与OneOs两种主流定位服务提供了完整的配置指南。文章结合常见错误码(如126、127)和硬件注意事项,分享了确保定位成功的实战经验与稳健的程序框架。

weixin_29057695的博客 489

stm32cubeMX使用HAL库点亮LED流水灯

目录

weixin_46129506的博客 3798

关于使用VB.NET判断打印机纸张大小

Console.WriteLine($"尺寸: {paperSize.Width} x {paperSize.Height} (0.01英寸单位)")在 VB.NET 中,可通过 `System.Drawing.Printing` 命名空间获取打印机纸张信息。上述方法获取的是*预设规格*,如需检测实际装载的纸张(如通过传感器),需调用打印机厂商的特定 API。此方法返回当前默认打印机的预设纸张名称(如 "A4"、"Letter" 等)。4. 如何通过 VB.NET 设置打印机的自定义纸张尺寸?

cncbook1979的博客 533

2022年TI杯模拟电⼦系统设计专题邀请赛——李萨如图形演示装置

本次装置主要是对输入的正弦信号进行频率变换,并将原输入正弦信号作为 X 轴信号、变换后的正弦信号作为 Y 轴信号,绘制李萨如图形。采用 EK-TM4C123GXL 板卡作为主控;频率变换采用“锁向环+计数器”实现 1-5 倍频的频率变换控制;李萨如图形采用两个 AD通道采集原输入的正弦信号作为 X 轴信号和频率变换后的正弦信号作为 Y 轴信号,绘制李萨如图形。

qq_45890466的博客 7769

vb 如何检测打印机是否联机_打印机提示该文档未能打印导致打印失败的原因及解决方法...

打印机打印时,一直出现该文档未能打印的提示,如何解决这个问题?在使用打印机的时候,偶尔会出现提示该文档未能打印,打印失败的状况,这是怎么回事?下面就给大家分析下具体原因及其解决办法。一、打印机处于脱机状态解决办法:检查打印机与电脑主机之间的数据线连接,一切正常后,检查打印机电源是否开启,再之后进入控制面板在找到打印机,然后在打印机上右键,选择“联机打印”即可。如果问题依旧,请检查USB接口是否存在...

weixin_39520393的博客 867

从零到一:DETR模型在自定义数据集上的实战部署与调优

本文详细介绍了DETR模型在自定义数据集上的实战部署与调优过程,包括环境准备、数据转换、模型配置、训练技巧及问题排查。通过具体代码示例和实用建议,帮助开发者高效完成从零到一的DETR模型部署,特别适合目标检测领域的实践应用。

weixin_42524100的博客 463

Supermind量化实战:我如何给双均线策略加上“止损”和“仓位管理”,让回测收益更稳健

本文详细介绍了如何在Supermind平台上为双均线策略添加止损和仓位管理模块,以提升量化交易的稳健性。通过Python实现动态止损和智能仓位管理,策略的年化收益率从12.3%提升至15.8%,最大回撤从58.7%降至22.4%,Sharpe比率显著提高。这些实战技巧适用于量化交易爱好者,帮助他们在黑天鹅行情中保持收益稳定。

weixin_42567752的博客 363

c#打印机脱机检查及阻塞打印

在使用winform编写自sql教程动打印服务的java基础教程过程中,发现只要进行python基础教程了打印命令的调用,文档就c#教程会进入到打印等待队列,如果打印vb.net教程机无法正常工作,则会影响到相关业务数据的正确转换,所以需要检查打印机的状态来保障每次打印时打印机处于空闲状态,打印时队列中也只能有一个文档,本文是通过引用System.Management来实现对打印机状态的查询 打印机状态获取 enum PrinterStatus {

chinaherolts2008的博客 790

Vue + ECharts:从零构建智慧农业数据监控大屏(附完整源码)」 「超实用!一步步实现智慧农业大屏,完整代码+讲解」 「前端新手友好:Vue + ECharts 打造炫酷农业数据大屏」 「

Vue + ECharts:从零构建智慧农业数据监控大屏(附完整源码)」 「超实用!一步步实现智慧农业大屏,完整代码+讲解」 「前端新手友好:Vue + ECharts 打造炫酷农业数据大屏」 「前端可视化项目实战:智慧农业监控大屏开发详解」 「农作物可视化监控:用 Vue 和 ECharts 构建大屏应用」 「从零开始开发一个智慧农业数据大屏(代码+图表展示)」 「前端新手也能实现!智慧农业监控大屏开发教程」 「用 Vue 和 ECharts 搭建动态数据大屏:详细图文教程」 「学习前端大屏开发:

sky10100100的博客 1535
上一篇: 预告:kylefly将陆续上传下列内容
下一篇: Windows Mobile 5.0 + SQL Moblile 开发示例
kylefei
博客等级 码龄23年 1粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值