Windows print spool manager setjob function not working for windows-7?

I am updating our Printer Monitoring application. Previously, this application ran successfully on a Windows 2000 server. Now we switched to a Windows 7 server. In Windows 7, the Print Monitor application crashed. When I debug it, I found that our SetJob function throws the following exception:

Invalid parameter.

Does anyone know about this?

Function call:

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

The Spooler API 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 
+6
source share
1 answer

Please write here how the function should be built and how the parameters are called:

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

This is a little different than you implemented it. Hope this helps.

0
source

Source: https://habr.com/ru/post/889381/


All Articles