示例#1
0
文件: Form1.cs 项目: rambom/Source
        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("进程不存在!");
                }
            }
        }
示例#2
0
文件: Form1.cs 项目: rambom/Source
 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);
         }
     }
 }