Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            bool blnExist = false;

            if (!string.IsNullOrEmpty(this.textBox2.Text))
            {
                listBox1.Items.Clear();
                int intPid = int.Parse(textBox2.Text);
                foreach (Process p in Process.GetProcesses())
                {
                    if (p.Id.Equals(intPid))
                    {
                        SortedList hwndList = User32API.GetWindowHandle(intPid);
                        foreach (DictionaryEntry obj in hwndList)
                        {
                            listBox1.Items.Add(obj.Key);
                        }
                        blnExist = true;
                        return;
                    }
                }
                if (!blnExist)
                {
                    MessageBox.Show("进程不存在!");
                }
            }
        }
Exemple #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex == -1)
     {
         MessageBox.Show("未选择窗体句柄!");
     }
     else
     {
         IntPtr hwnd = (IntPtr)int.Parse(listBox1.SelectedItem.ToString());
         if (hwnd != IntPtr.Zero)
         {
             User32API.ShowWindow(hwnd, 0);
         }
     }
 }