Exemplo n.º 1
0
        /// <summary>
        /// 句柄查找
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFindForm_Click(object sender, EventArgs e)
        {
            Process[] ps = Process.GetProcessesByName(this.txtExeName.Text).Where(x => x.MainWindowHandle != IntPtr.Zero).ToArray();

            if (ps.Length == 0)
            {
                MessageBox.Show("目标程序未启动");
                return;
            }
            else if (ps.Length == 1)
            {
                processInfo           = new ProcessInfo();
                processInfo._Handle   = ps[0].MainWindowHandle;
                processInfo._Image    = WinApi.GetWindowCapture(processInfo._Handle);
                processInfo._Location = processInfo._Image._screenLoca1;
                processInfo._Name     = this.txtExeName.Text;
                this.picProcess.Image = Common.GetThumbnail(processInfo._Image._img.Clone() as Bitmap, picProcess.Height, this.picProcess.Width);
            }
            else
            {
                AllProcessForm f = new AllProcessForm(ps);
                if (f.ShowDialog() == DialogResult.OK)
                {
                    this.txtExeName.Text  = f.SelectedName;
                    processInfo           = new ProcessInfo();
                    processInfo._Handle   = f.SelectedHandle;
                    processInfo._Image    = WinApi.GetWindowCapture(processInfo._Handle);
                    processInfo._Location = processInfo._Image._screenLoca1;
                    processInfo._Name     = this.txtExeName.Text;
                    this.picProcess.Image = Common.GetThumbnail(processInfo._Image._img.Clone() as Bitmap, picProcess.Height, this.picProcess.Width);
                }
            }
        }
Exemplo n.º 2
0
        private void btnShowAllProcess_Click(object sender, EventArgs e)
        {
            AllProcessForm f = new AllProcessForm();

            if (f.ShowDialog() == DialogResult.OK)
            {
                this.txtExeName.Text  = f.SelectedName;
                processInfo           = new ProcessInfo();
                processInfo._Handle   = f.SelectedHandle;
                processInfo._Image    = WinApi.GetWindowCapture(processInfo._Handle);
                processInfo._Location = processInfo._Image._screenLoca1;
                processInfo._Name     = this.txtExeName.Text;
                this.picProcess.Image = Common.GetThumbnail(processInfo._Image._img.Clone() as Bitmap, picProcess.Height, this.picProcess.Width);
            }
        }