title: System Error 183 from print call (ERROR_ALREADY_EXISTS)
body: <p>I am trying to get a test page printed from the <a href="https://code.msdn.microsoft.com/windowshardware/Windows-8-Driver-Samples-5e1aa62e" rel="nofollow">Windows Driver Kit (WDK) 8.1 Samples</a> (the bitmap sample). Since I did not get any print output, I placed a "GetLastError" call after each call to 'DrvWriteSpoolBuf":</p>
  
  <pre><code>dwWritten = pDevObj-&gt;pDrvProcs-&gt;DrvWriteSpoolBuf(pDevObj, (void*)&amp;(pOemPDEV-&gt;bmFileHeader), sizeof(BITMAPFILEHEADER));
  
  DWORD pdwReturn = GetLastError();
  if (pdwReturn != ERROR_SUCCESS)
      ERR("OEMEndDoc: Error printing=%ld\n", pdwReturn); 
  </code></pre>
  
  <p>I received Error 183 !!! From <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx" rel="nofollow">System Error Codes</a>:</p>
  
  <pre><code>ERROR_ALREADY_EXISTS
  183 (0xB7)
  Cannot create a file when that file already exists.
  </code></pre>
  
  <p>Alternate version of call above</p>
  
  <pre><code>DWORD res = pOemPDEV-&gt;pOEMHelp-&gt;DrvWriteSpoolBuf(pDevObj, &amp;(pOemPDEV-&gt;bmFileHeader), sizeof(BITMAPFILEHEADER), &amp;dwWritten);
  </code></pre>
  
  <p><strong>I get res=E_FAIL</strong></p>
  
  <p>(apology for using bold - comments seem to overlook this result though)</p>
  
  <p>How can I get such an error from printing ? (either to LPT1 or FILE: port)</p>
  
  <p>I have tested the code by saving to a bitmap the exact contents I am trying to send to he spooler, the bitmap was created correctly. </p>
  
  <p>...I apologize for not including more code, it is available at the link I posted above... <a href="https://code.msdn.microsoft.com/windowshardware/Windows-8-Driver-Samples-5e1aa62e" rel="nofollow">Windows Driver Kit (WDK) 8.1 Samples</a></p>
  
  <p>Windows Driver Kit (WDK) 8.1 Samples\OEM Printer Customization Plug-in Samples\C++\bitmap</p>