Esempio n. 1
0
        private void ShowForegroundWindow(object sender, EventArgs e)
        {
            var FW = GetForegroundWindow();

            /*
             * StringBuilder SB = new StringBuilder();
             * //char[] filepath = new char[10000];
             * //uint maxfilepathlength = 1000;
             * try
             * {
             *  GetWindowText(FW, SB, 1000);
             * }
             * catch (Exception ex)
             * {
             *  Debug.Write(ex.Message);
             * }
             */
            //Debug.Write(SB);
            //QueryFullProcessImageName(new IntPtr(GetCurrentProcessID(FW)), 0, filepath, ref maxfilepathlength);
            var P  = Process.GetProcessById(GetCurrentProcessID(FW));
            var PP = FindHostedProcess.Find();

            if (PP == null)
            {
                return;
            }
            TB.Text = PP.ProcessName + "|" + PP.MainModule.FileName + "|" + PP.MainWindowTitle;
            //Bitmap img = Consts.Base64String2Icon(Consts.Icon2Base64String(System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName))).ToBitmap();
            Icon icon  = System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName);
            Icon icon2 = Consts.Base64String2Icon(Consts.Icon2Base64String(icon));

            IMG.Source = Consts.ChangeBitmapToImageSource(icon2.ToBitmap());
        }
Esempio n. 2
0
        public static void ShowForegroundWindow(object sender, EventArgs e)
        {
            var t1 = new Task(() =>
            {
                try
                {
                    var PP = FindHostedProcess.Find();
                    if (PP == null)
                    {
                        return;
                    }
                    //TB.Text = PP.ProcessName + "|" + PP.MainModule.FileName + "|" + PP.MainWindowTitle;
                    Icon i         = System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName);
                    Data.Actions A = new Data.Actions();
                    A.DateTime     = DateTime.Now;
                    A.Type         = 0;
                    A.Action       = PP.MainModule.FileName;
                    A.Title        = PP.MainWindowTitle;
                    A.Icon         = i;
                    if (LastActions == null || LastActions.Action != A.Action || LastActions.Title != A.Title)
                    {
                        Data.AddActions(A);
                        LastActions = A;
                    }
                }
                catch
                {
                }
            });

            t1.Start();
        }