title: Windows printer spooler setjob function not working for Windows-7?
body: <p>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 <code>SetJob</code> function throws the following exception:</p>
  
  <blockquote>
    <p>The parameter is incorrect.</p>
  </blockquote>
  
  <p>Does anyone know anything about this?</p>
  
  <p>Function call:</p>
  
  <pre><code>SetJob(
      mhPrinter,
      midJob,
      0,
      IntPtr.Zero,
      PrintJobControlCommands.JOB_CONTROL_PAUSE) 'Here exception is thrown
  </code></pre>
  
  <p>Spooler API which we use :</p>
  
  <pre><code>&lt;DllImport("winspool.drv", EntryPoint:="SetJob", _
  
  SetLastError:=True, CharSet:=CharSet.Ansi, _
  
  ExactSpelling:=False, _
  
  CallingConvention:=CallingConvention.StdCall)&gt; _
  
  Public Function SetJob _
  
  (&lt;InAttribute()&gt; ByVal hPrinter As IntPtr, _
  
  &lt;InAttribute()&gt; ByVal dwJobId As Int32, _
  
  &lt;InAttribute()&gt; ByVal Level As Int32, _
  
  &lt;InAttribute()&gt; ByVal lpJob As IntPtr, _
  
  &lt;InAttribute(), MarshalAs(UnmanagedType.U4)&gt; ByVal dwCommand As PrintJobControlCommands _
  
  ) As Boolean
  </code></pre>