search for specific window on rapi

May 4, 2012 at 12:34 AM

I want to check if some process is running i saw in the RAPI reference the methods for getwindow and getwindowtext   i finally got that running.

i think it can be added to the library

        public bool TaskIsRunning(string windowName)        {            IntPtr ptr = CeGetWindow(IntPtr.Zero, GetWindow_Cmd.GW_CHILD);            ptr = CeGetWindow(ptr, GetWindow_Cmd.GW_HWNDLAST);
            while (ptr != IntPtr.Zero)            {                StringBuilder sb = new StringBuilder(255);                int a = CeGetWindowText(ptr, sb, 255);                System.Diagnostics.Debug.WriteLine(a + " " + sb.ToString());                if (sb.ToString() == windowName)                    return true;                ptr = CeGetWindow(ptr, GetWindow_Cmd.GW_HWNDPREV);            }
            return false;        }

 

 

        [DllImport("rapi.dll", SetLastError = true)]        internal static extern IntPtr CeGetWindow(IntPtr hWnd, GetWindow_Cmd uCmd);
        [DllImport("rapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]        internal static extern int CeGetWindowText(IntPtr hWnd, StringBuilder name, int nMaxCount);
        public enum GetWindow_Cmd : uint        {            GW_HWNDFIRST = 0,            GW_HWNDLAST = 1,            GW_HWNDNEXT = 2,            GW_HWNDPREV = 3,            GW_OWNER = 4,            GW_CHILD = 5,            GW_ENABLEDPOPUP = 6        }

Developer
Jul 12, 2012 at 10:30 PM

If you want to see that code in the library please provide a patch. Thanks.