Beispiel #1
0
        /// <summary>
        /// Gets the process ID of the process that created the first window to match the given window title.
        /// </summary>
        /// <param name="WindowTitle">Title of the main window whose process id we want.</param>
        /// <returns>Returns non-zero on success, zero on failure.</returns>
        public static int GetProcessFromWindowTitle(string WindowTitle)
        {
            IntPtr hWnd = SWindow.FindWindow(null, WindowTitle);

            if (hWnd == IntPtr.Zero)
            {
                return(0);
            }

            return(GetProcessFromWindow(hWnd));
        }
Beispiel #2
0
        /// <summary>
        /// Gets the process ID of the process that created the first window to match the given window title.
        /// </summary>
        /// <param name="Classname">Classname of the main window whose process id we want.</param>
        /// <returns>Returns non-zero on success, zero on failure.</returns>
        public static int GetProcessFromClassname(string Classname)
        {
            IntPtr hWnd = SWindow.FindWindow(Classname, null);

            if (hWnd == IntPtr.Zero)
            {
                return(0);
            }

            return(GetProcessFromWindow(hWnd));
        }