public static void AppActivate(string Title)
        {
            string lpClassName = null;
            IntPtr hWnd        = Microsoft.VisualBasic.CompilerServices.NativeMethods.FindWindow(ref lpClassName, ref Title);

            if (hWnd == IntPtr.Zero)
            {
                int           num;
                string        strA     = string.Empty;
                StringBuilder lpString = new StringBuilder(0x1ff);
                int           length   = Strings.Len(Title);
                hWnd = Microsoft.VisualBasic.CompilerServices.NativeMethods.GetWindow(Microsoft.VisualBasic.CompilerServices.NativeMethods.GetDesktopWindow(), 5);
                while (hWnd != IntPtr.Zero)
                {
                    num  = Microsoft.VisualBasic.CompilerServices.NativeMethods.GetWindowText(hWnd, lpString, lpString.Capacity);
                    strA = lpString.ToString();
                    if ((num >= length) && (string.Compare(strA, 0, Title, 0, length, StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        break;
                    }
                    hWnd = Microsoft.VisualBasic.CompilerServices.NativeMethods.GetWindow(hWnd, 2);
                }
                if (hWnd == IntPtr.Zero)
                {
                    hWnd = Microsoft.VisualBasic.CompilerServices.NativeMethods.GetWindow(Microsoft.VisualBasic.CompilerServices.NativeMethods.GetDesktopWindow(), 5);
                    while (hWnd != IntPtr.Zero)
                    {
                        num  = Microsoft.VisualBasic.CompilerServices.NativeMethods.GetWindowText(hWnd, lpString, lpString.Capacity);
                        strA = lpString.ToString();
                        if ((num >= length) && (string.Compare(Strings.Right(strA, length), 0, Title, 0, length, StringComparison.OrdinalIgnoreCase) == 0))
                        {
                            break;
                        }
                        hWnd = Microsoft.VisualBasic.CompilerServices.NativeMethods.GetWindow(hWnd, 2);
                    }
                }
            }
            if (hWnd == IntPtr.Zero)
            {
                throw new ArgumentException(Utils.GetResourceString("ProcessNotFound", new string[] { Title }));
            }
            AppActivateHelper(hWnd);
        }
Exemplo n.º 2
0
 /// <summary>
 /// hàm thực hiện lấy barcode cho bệnh nhân
 /// </summary>
 /// <param name="sOrder"></param>
 /// <returns></returns>
 public string GetPid(string sOrder)
 {
     return(DateAndTime.Now.Year + VB6.Right("0" + DateAndTime.Now.Month, 2) +
            VB6.Right("0" + DateAndTime.Now.Day, 2) + VB6.Right("0" + DateAndTime.Now.Hour, 2) +
            VB6.Right("0" + DateAndTime.Now.Minute, 2) + VB6.Right("0" + DateAndTime.Now.Second, 2) + sOrder);
 }