Windows printer spooler setjob function not working for Windows-7?
Asked Answered
A

1

6

I am updating our "Printer Monitoring" application. Previously this application runs successfully on Windows 2000 server. Now we shifted to Windows 7 server. On windows 7 our "Print monitor" application crashes. When I debug it, I found that our SetJob function throws the following exception:

The parameter is incorrect.

Does anyone know anything about this?

Function call:

SetJob(
    mhPrinter,
    midJob,
    0,
    IntPtr.Zero,
    PrintJobControlCommands.JOB_CONTROL_PAUSE) 'Here exception is thrown

Spooler API which we use :

<DllImport("winspool.drv", EntryPoint:="SetJob", _

SetLastError:=True, CharSet:=CharSet.Ansi, _

ExactSpelling:=False, _

CallingConvention:=CallingConvention.StdCall)> _

Public Function SetJob _

(<InAttribute()> ByVal hPrinter As IntPtr, _

<InAttribute()> ByVal dwJobId As Int32, _

<InAttribute()> ByVal Level As Int32, _

<InAttribute()> ByVal lpJob As IntPtr, _

<InAttribute(), MarshalAs(UnmanagedType.U4)> ByVal dwCommand As PrintJobControlCommands _

) As Boolean
Arrear answered 30/5, 2011 at 13:34 Comment(3)
That API call has not changed on Windows7. That exception generally means that you either have an invalid JobId, or that the JobId is not associated with that Printer handle. From windows Vista onwards MS introduced Client Side Rendering (CSR) to improve printing efficiency, this can have the appearance of jobs running through the spooler multiple times, maybe there is some other bug in your code somewhere else causing a mismatch.Bal
When you say "Windows 7 Server" can we assume you mean "Windows Server 2008 R2"? I'm assuming based on the tag.Vaporous
Do you get any entries in the event log that provide event ids?Vaporous
T
0

Please have a loop here, how the function has to be build and how the parsmeters are called:

http://www.pinvoke.net/default.aspx/winspool.setjob

It is a bit different then you implemented it. Hope it will help.

Titanism answered 30/12, 2015 at 19:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.