如何捕捉WINDWOS系统错误窗口 想请教下 WINDWOS系统错误时会弹出错误窗体.不按确定就会令系统阻塞其他程序无法运行..希望用C#写一个程序.当出误错误窗口.自动按确定吗请各位大大个一些例子源码.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FindWindowEx(FindWindow("窗口标题", null), 0, "按钮文本", null) 自己做一个错误窗口 *****************************************************************************欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/ // 开始--》运行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"); } } 难道又要搞windows api,c#不适合做这些工作。 C#下没搞过,C++下最好用Hook窗口过程来做,比FindWindow要好很多 ASP.NET自定义控件 数据类型转换问题 请教大师,程序利用线程使读上万条数据,不假死 winforms 程序 连同 framework 一起打包 。 C#中如何做主窗口和登录窗口? 明明已引用,为啥还说我没引用? 新手,没什么分,请大峡帮忙看看这个程序错哪了``谢谢 请教c#调用dll 的问题 SDK里面的例子,但是看不明白,请大家帮忙解析下。 DSOFRAMER保存问题,超过5M的内容就保存不了???急急急 请教,如何将用C#开发完的类库生成的DLL,转换成在非托管编程环境下可以用COM。 运行拖拽时如何判断鼠标在控件的边角上
FindWindowEx(FindWindow("窗口标题", null), 0, "按钮文本", null)
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
// 开始--》运行
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");
}
}