[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Windows Print Queue information using VB

Posted on 2000-01-03
9
Medium Priority
?
181 Views
Last Modified: 2010-05-02
Is there a way,using VB, to monitor the status of a local print job in Win95? I would like to monitor a print job that was sent from VB, and find out when it is finished. I have a system with data acquisition hardware installed, and I'm doing real time acquisition. When I send something to the local printer, as soon as I see the printing icon, I seem to get a glitch in my data acquisition. I would like to suspend all acquisition until printing is complete, so I need to somehow monitor this process.

THank you

Jeff
0
Comment
Question by:jscharpf
  • 5
  • 4
9 Comments
 
LVL 2

Accepted Solution

by:
adityau earned 400 total points
ID: 2322273
Paste the following code onto a form and add a command button with name command1

Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
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

Dim strPrinterDeviceName    As String
Dim lngPrinterHandle        As Long
Dim lngJobInfo1FirstJob     As Long
Dim lngJobInfo1EnumerateJob As Long
Dim lngJobInfo1Level        As Long
Dim lngJobInfo1Needed       As Long
Dim lngJobInfo1Returned     As Long
Dim lngWin32apiResultCode   As Long

Private Function glbfunPrinterStatus() As String
    strPrinterDeviceName = Printer.DeviceName
    lngWin32apiResultCode = OpenPrinter(strPrinterDeviceName, lngPrinterHandle, ByVal vbNullString)
    lngJobInfo1FirstJob = 0
    lngJobInfo1EnumerateJob = 99
    lngJobInfo1Level = 1
    lngWin32apiResultCode = EnumJobs(lngPrinterHandle, lngJobInfo1FirstJob, lngJobInfo1EnumerateJob, lngJobInfo1Level, ByVal vbNullString, 0, lngJobInfo1Needed, lngJobInfo1Returned)
    If lngJobInfo1Needed > 0 Then
        glbfunPrinterStatus = "Busy"
    Else
        glbfunPrinterStatus = "Not Busy"
    End If
End Function

Private Sub Command1_Click()
    MsgBox glbfunPrinterStatus
End Sub
0
 

Author Comment

by:jscharpf
ID: 2322854
I'm using VB 4.0 16 bit, and I get errors in the first function indicating some type of mismatch. My guess is that your sample code was for 32 bit? Is there a way to find this same function using the API text viewer or something to see if the 16 bit call is the same?
0
 

Author Comment

by:jscharpf
ID: 2322900
I'm using VB 4.0 16 bit, and I get errors in the first function indicating some type of mismatch. My guess is that your sample code was for 32 bit? Is there a way to find this same function using the API text viewer or something to see if the 16 bit call is the same?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Expert Comment

by:adityau
ID: 2323329
You try to use 0& instead of vbNullString. It might work. Otherwise, I will findout and tell u tomorrow as I am leaving to home now.
0
 

Author Comment

by:jscharpf
ID: 2323499
When I use VB 4.0 32 bit,it works fine. On the same machine, when I use VB 4.0 16 bit, it says "Run Time Error 48. Error loading DLL"

In the meantime, I'll try your advice.

Jeff
0
 
LVL 2

Expert Comment

by:adityau
ID: 2324967
The problem is OpenPrinter is a function Winspool.drv which is 32 bit. For 16 bit, there is a Winspl16.drv file, but there is no OpenPrinter function in that. There may be an equivalent function in that. I don't have 16 bit documentation. But, it is at my home and I will be going this weekend. If you want, I can get it for you. Meanwhile, if you have 16 bit documentation (may be VC 4.0 16 bit), please go through the documentation and findout the equivalent function for OpenPrinter.
0
 

Author Comment

by:jscharpf
ID: 2325860
Thank you for your help. I will try to find the documentation. If you do find it at home and wish to email it to me, please do! I will post the points, as you have sent me in the right direction.

Thanks,

Jeff
0
 
LVL 2

Expert Comment

by:adityau
ID: 2325895
Please send me your e-mail id to me. I will try to findout and let you know if I can get the solution on VB4 16 bit. My e-mail id is

aditya@cgs.cgsmith.soft.net
0
 

Author Comment

by:jscharpf
ID: 2325925
Jeffrey_Scharpf@mil-elect-tool.com

Thanks!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question