Esempio n. 1
0
 public void Dispose()
 {
     if (!WindowsApi.SetThreadDesktop(originalDesktop))
     {
         WindowsHelpers.CheckLastError();
     }
 }
Esempio n. 2
0
 public void Dispose()
 {
     if (!WindowsApi.CloseDesktop(Handle))
     {
         WindowsHelpers.CheckLastError();
     }
 }
        public int?GetExitCode()
        {
            if (!WindowsApi.GetExitCodeProcess(processInformation.hProcess, out var exitCode))
            {
                WindowsHelpers.CheckLastError();
            }

            return(exitCode == 259 /* STILL_ACTIVE */ ? null : (int?)exitCode);
        }
Esempio n. 4
0
        public Desktop(string baseName)
        {
            Name = baseName + " " + DateTime.Now.Ticks.ToString(); //Ensuring this is unique since sometimes a name can't be reused later on

            Handle = WindowsApi.CreateDesktop(Name, null, null, 0, WindowsApi.ACCESS_MASK.DESKTOP_CREATEWINDOW, null);
            if (Handle == IntPtr.Zero)
            {
                WindowsHelpers.CheckLastError();
            }
        }
        public void Dispose()
        {
            if (!WindowsApi.CloseHandle(processInformation.hProcess))
            {
                WindowsHelpers.CheckLastError();
            }

            if (!WindowsApi.CloseHandle(processInformation.hThread))
            {
                WindowsHelpers.CheckLastError();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Switches to the <paramref name="newDesktopHandle"/> desktop.
        /// </summary>
        public DesktopContext(IntPtr newDesktopHandle)
        {
            originalDesktop = WindowsApi.GetThreadDesktop(WindowsApi.GetCurrentThreadId());
            if (originalDesktop == IntPtr.Zero)
            {
                WindowsHelpers.CheckLastError();
            }

            if (!WindowsApi.SetThreadDesktop(newDesktopHandle))
            {
                WindowsHelpers.CheckLastError();
            }
        }
        public DesktopProcess(string commandLine, string desktopName)
        {
            var startupInfo = new WindowsApi.STARTUPINFO
            {
                cb        = Marshal.SizeOf <WindowsApi.STARTUPINFO>(),
                lpDesktop = desktopName,
            };

            if (!WindowsApi.CreateProcess(
                    null,
                    commandLine,
                    null,
                    null,
                    true,
                    0,
                    IntPtr.Zero,
                    null,
                    ref startupInfo,
                    out processInformation
                    ))
            {
                WindowsHelpers.CheckLastError();
            }
        }