Results 1 to 3 of 3

Thread: Communicating with printer

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    11

    Communicating with printer

    I am sending files to the printer using the print 'file' command from windows in a loop to run through the whole list of files a number of times.
    I would like to keep track of the nr of times this loop has run through, but not based on the loop itself, but on the nr of commands that the printer has accepted and finished. Meaning: my progressbar and numbering should only increase when the printer has finished its job. Is there a way to communicate with the printer to get to know this? It is a parallell printer using generic windows drivers.

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    11

    Re: Communicating with printer

    Anyone any idea please?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Communicating with printer

    This example from allapi.net should help get you started.
    VB Code:
    1. Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
    2. Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
    3. Private 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 Any, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long
    4. Private Sub Form_Load()
    5.     'KPD-Team 2001
    6.     'URL: [url]http://www.allapi.net/[/url]
    7.     'E-Mail: [email][email protected][/email]
    8.     Dim hPrinter As Long, lNeeded As Long, lReturned As Long
    9.     Dim lJobCount As Long
    10.     OpenPrinter Printer.DeviceName, hPrinter, ByVal 0&
    11.     EnumJobs hPrinter, 0, 99, 1, ByVal 0&, 0, lNeeded, lReturned
    12.     If lNeeded > 0 Then
    13.         ReDim byteJobsBuffer(lNeeded - 1) As Byte
    14.         EnumJobs hPrinter, 0, 99, 1, byteJobsBuffer(0), lNeeded, lNeeded, lReturned
    15.         If lReturned > 0 Then
    16.             lJobCount = lReturned
    17.         Else
    18.             lJobCount = 0
    19.         End If
    20.     Else
    21.         lJobCount = 0
    22.     End If
    23.     ClosePrinter hPrinter
    24.     MsgBox "Jobs in printer queue: " + CStr(lJobCount), vbInformation
    25. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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