想请教下 WINDWOS系统错误时会弹出错误窗体.不按确定就会令系统阻塞其他程序无法运行..希望用C#写一个程序.当出误错误窗口.自动按确定吗请各位大大个一些例子源码..

解决方案 »

  1.   


    FindWindowEx(FindWindow("窗口标题", null), 0, "按钮文本", null)
      

  2.   

    自己做一个错误窗口
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  3.   

     
                // 开始--》运行
    using System.Runtime.InteropServices;        [DllImport("user32.dll")]
            static extern int FindWindow(string lpClassName, string lpWindowName);
            [DllImport("user32.dll")]
            static extern int GetDlgItem(int hDlg, int nIDDlgItem);
            [DllImport("user32.dll", SetLastError = true)]
            public static extern int FindWindowEx(int parentHandle, int childAfter, string className, string windowTitle);
            [DllImport("user32.dll", EntryPoint = "SendMessage")]
            static extern int SendMessage(int hWnd, uint Msg, int wParam, string lParam);
            private const uint WM_SETTEXT = 0x000C;
            private const int WM_CLICK = 0xF5;        private void button1_Click(object sender, EventArgs e)
            {
                int h1 = 0, h2 = 0, h3;
                h1 = FindWindow(null, "运行");    //这要修改为窗口标题 
                if (h1 != 0)
                {
                    h2 = FindWindowEx(h1, 0, "ComboBox", null);
                    if (h2 != 0)
                    {
                        SendMessage(h2, WM_SETTEXT, 0, "Regedit.exe");
                        h3 = FindWindowEx(h1, 0, null, "确定");    //这要修改为按钮文本 
                        if (h3 != 0)
                        {
                            SendMessage(h3, WM_CLICK, 0, null);
                        }
                        else
                        {
                            MessageBox.Show("h3==0");
                        }
                    }
                    else
                    {
                        MessageBox.Show("h2==0");
                    }
                }
                else
                {
                    MessageBox.Show("h1==0");
                }
            }
      

  4.   

    难道又要搞windows api,c#不适合做这些工作。
      

  5.   

    C#下没搞过,C++下最好用Hook窗口过程来做,比FindWindow要好很多