Esempio n. 1
0
        private void StartClientServer(object obj)
        {
            uint currentProcId = Win32APIs.GetCurrentProcessId();

            if (m_Table == null || m_TestDllPath == null)
            {
                return;
            }
            List <string> testCases   = (List <string>)m_Table[currentProcId];
            List <Type>   testTobeRun = new List <Type>();

            if (testCases == null || testCases.Count == 0)
            {
                return;
            }

            Assembly asm = Assembly.LoadFile(m_TestDllPath);

            foreach (string item in testCases)
            {
                Type t = asm.GetType(item);
                testTobeRun.Add(t);
            }
            RunTests(testTobeRun);
        }
Esempio n. 2
0
        private void FindWindow_ThreadProc(object param)
        {
            IntPtr ptrToString = Marshal.StringToHGlobalUni((string)param);
            bool   bresult     = Win32APIs.EnumWindows(FindWinForm, ptrToString);

            m_WindowFoundEvent.Set();
        }
Esempio n. 3
0
 public IntPtr FindWindowAsynch(string windowName, int timeOut, out uint procId)
 {
     procId  = 0;
     m_Index = 0;
     FindWindowAsynch(windowName, timeOut);
     if (m_WindowFound)
     {
         Win32APIs.GetWindowThreadProcessId(m_WindowHandle, out procId);
         return(m_WindowHandle);
     }
     else
     {
         return(IntPtr.Zero);
     }
 }
Esempio n. 4
0
        private int FindWinForm(IntPtr hwnd, IntPtr lparam)
        {
            if (hwnd == null)
            {
                return(1);//true
            }
            if (Win32APIs.IsWindow(hwnd) && Win32APIs.IsWindowVisible(hwnd))
            {
                string        windowname   = Marshal.PtrToStringUni(lparam);
                StringBuilder stringBuffer = new StringBuilder(256);

                int    result = Win32APIs.GetWindowText(hwnd, stringBuffer, 256);
                string temp   = stringBuffer.ToString();
                bool   found  = false;
                if (exactMatch)
                {
                    found = temp.Equals(windowname);
                }
                else
                {
                    found = temp.Contains(windowname);
                }
                if (found)
                {
                    if (m_Index == 0)//if user is interested in forst occurence then return
                    {
                        m_WindowHandle = hwnd;
                        m_WindowFound  = true;
                        return(0);
                    }
                    else//maybe user is interested in nth occurence so keep looking
                    {
                        m_Index--;
                        return(1);
                    }
                }
            }
            return(1);
        }