title: Trouble when call AddPrinterDriver - winspool.drv
body: <p>I'm trying to create a virtual printer using c# with some binding function from winspool.drv, I have successfully installed the printer into my windows 7 64bits, but win32 always causes the error code 216 whenever I try to install on a 32bits machine.</p>
  
  <p>I decided to borrow my friends' computer, in which 10 computers with 32bit processor, there are only one can install the printer driver.</p>
  
  <p>The error happend when I call AddPrinterDriver method. And here is my code:</p>
  
  <pre><code>[DllImport("winspool.drv", EntryPoint = "AddPrinterDriver", CharSet = CharSet.Auto, SetLastError = true)]
  internal static extern bool AddPrinterDriver(String pName, int Level, ref DRIVER_INFO_6 pDriverInfo);
  </code></pre>
  
  <p>Code to call it with </p>
  
  <pre><code>private bool InstallPrinterDriver(ref DRIVER_INFO_6 printerDriverInfo)
  {
      bool printerDriverInstalled = false;
      printerDriverInstalled = NativeMethods.AddPrinterDriver(null, 6, ref printerDriverInfo);
      if (printerDriverInstalled == false)
      {
          //int lastWinError = Marshal.GetLastWin32Error();
          //throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add printer Zody PDF printer driver.");
          logEventSource.TraceEvent(TraceEventType.Error,
                                        (int)TraceEventType.Error,
                                        "Could not add Zody PDF printer driver. " +
                                        String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
          Console.Write("\n" + String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
          Console.Write("\n"+printerDriverInfo);
      }
      return printerDriverInstalled;
  }
  </code></pre>
  
  <p>The result is always failed with error code 216 even I had tried so many ways like change the pEnvironment = null or Windows NT x86. Then run with admin privileges and so on. </p>
  
  <p>Update: the error 216's explanation:  This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
  -> that means I may running a 64bits program on a 32bits one. But, I'm pretty sure that the package has been built on a target of 32bit (x86) machine from Visual studio 2015. </p>