title: PInvoke CreateDesktop
body: <p>I am trying to PInvoke CreateDesktop in a way that passes the flag to inherit the desktop by child processes. The declaration is as follows:</p>
  
  <pre><code>[DllImport("user32", EntryPoint = "CreateDesktopW", CharSet = CharSet.Unicode, SetLastError = true)]
          public static extern IntPtr CreateDesktop(string lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, int dwFlags,
                                                    int dwDesiredAccess, [MarshalAs(UnmanagedType.LPStruct)] SECURITY_ATTRIBUTES lpsa);
  
          [StructLayout(LayoutKind.Sequential)]
          public struct SECURITY_ATTRIBUTES
          {
              public int nLength;
              public IntPtr lpSecurityDescriptor;
              public int bInheritHandle;
          }
  </code></pre>
  
  <p>And I use it as follows:</p>
  
  <pre><code>Win32.SECURITY_ATTRIBUTES sa = new Win32.SECURITY_ATTRIBUTES();
              sa.nLength = Marshal.SizeOf(sa);
              sa.bInheritHandle = 1;
              testDesktopHandle = Win32.CreateDesktop(name, IntPtr.Zero, IntPtr.Zero, 0, Win32.GENERIC_ALL, sa);
  </code></pre>
  
  <p>And it unfortunately doesn't work, I get the following error:</p>
  
  <pre><code>System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #6': Invalid managed/unmanaged type combination (this value type must be paired with Struct).
  </code></pre>
  
  <p>Any ideas what I am doing wrong?</p>