CreateProcess in other desktop with lpDesktop
<p><strong>Update</strong></p>

<p><strong>The StartupInfomation struct need the ANSI charset.</strong></p>

<p>Hallo,</p>

<p>I'm want to create a new desktop and start an process there.
The creation of the desktop works probably. 
But if I create a process there by setting up the lpDesktop variable
I get an error "The Application failed to initialize properly (0xc0000142)".
I've already set the lpDesktop to "Default", "winsta0\Default" and to 
my other desktop name. Without changing the the lpDesktop var its starts
the process inside my default desktop.</p>

<pre><code>    public Process CreateProcess(string path, string commandline)
    {
        if (!IsCreated) return null;

        const uint normalPriorityClass = 0x0020;

        NativeMethods.ProcessInformation processInfo;
        var startInfo = new NativeMethods.StartupInfomation();
        var pSec = new NativeMethods.SecurityAttributes();
        var tSec = new NativeMethods.SecurityAttributes();

        startInfo.cb = Marshal.SizeOf(startInfo);
        startInfo.lpDesktop = Name;
        startInfo.lpTitle = Name;

        pSec.nLength = Marshal.SizeOf(pSec);
        tSec.nLength = Marshal.SizeOf(tSec);

        var result = NativeMethods.CreateProcess(path, commandline,
                                    ref pSec, ref tSec, true, normalPriorityClass,
                                    IntPtr.Zero, null, ref startInfo, out processInfo);

        return !result ? null : Process.GetProcessById(processInfo.dwProcessId);
    }
</code></pre>

<hr>

<pre><code>    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    internal struct StartupInfomation
    {
        public Int32 cb;
        public string lpReserved;
        public string lpDesktop;
        public string lpTitle;
        public Int32 dwX;
        public Int32 dwY;
        public Int32 dwXSize;
        public Int32 dwYSize;
        public Int32 dwXCountChars;
        public Int32 dwYCountChars;
        public Int32 dwFillAttribute;
        public Int32 dwFlags;
        public Int16 wShowWindow;
        public Int16 cbReserved2;
        public IntPtr lpReserved2;
        public IntPtr hStdInput;
        public IntPtr hStdOutput;
        public IntPtr hStdError;
    }
</code></pre>

<hr>

<pre><code>string desktopName = "otherDesktop";
IntPtr Handle = NativeMethods.CreateDesktop(desktopName, IntPtr.Zero, IntPtr.Zero, 0,
                                         NativeMethods.AccessMask.GenericAll, IntPtr.Zero);
NativeMethods.SwitchDesktop(handle);
NativeMethods.SetThreadDesktop(handle);
CreateProcess(Environment.GetEnvironmentVariable("windir") + @"\explorer.exe", null);
</code></pre>
