コード例 #1
0
        /// <summary>
        /// Creates a new desktop.  If a handle is open, it will be closed.
        /// </summary>
        /// <param name="name">The name of the new desktop.  Must be unique, and is case sensitive.</param>
        /// <returns>True if desktop was successfully created, otherwise false.</returns>
        public bool Create(string name)
        {
            // make sure object isnt disposed.
            CheckDisposed();

            // close the open desktop.
            if (m_desktop != IntPtr.Zero)
            {
                // attempt to close the desktop.
                if (!Close())
                {
                    return(false);
                }
            }

            // make sure desktop doesnt already exist.
            if (Desktop.Exists(name))
            {
                // it exists, so open it.
                return(Open(name));
            }

            // attempt to create desktop.
            m_desktop = CreateDesktop(name, IntPtr.Zero, IntPtr.Zero, 0, AccessRights, IntPtr.Zero);

            m_desktopName = name;

            // something went wrong.
            if (m_desktop == IntPtr.Zero)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new process on the specified desktop.
        /// </summary>
        /// <param name="path">Path to application.</param>
        /// <param name="desktop">Desktop name.</param>
        /// <returns>A Process object for the newly created process, otherwise, null.</returns>
        public static Process CreateProcess(string path, string desktop)
        {
            if (!Desktop.Exists(desktop))
            {
                return(null);
            }

            // create the process.
            Desktop d = Desktop.OpenDesktop(desktop);

            return(d.CreateProcess(path));
        }
コード例 #3
0
 /// <summary>
 /// Checks if the specified desktop exists (using a case sensitive search).
 /// </summary>
 /// <param name="name">The name of the desktop.</param>
 /// <returns>True if the desktop exists, otherwise false.</returns>
 public static bool Exists(string name)
 {
     return(Desktop.Exists(name, false));
 }