Windows Print Queue information using VB

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
jscharpfAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adityauCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jscharpfAuthor Commented:
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
jscharpfAuthor Commented:
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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

adityauCommented:
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
jscharpfAuthor Commented:
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
adityauCommented:
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
jscharpfAuthor Commented:
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
adityauCommented:
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
jscharpfAuthor Commented:
Jeffrey_Scharpf@mil-elect-tool.com

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.