[DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); public const int WM_CLOSE = 0x10; private System.ComponentModel.Container component = null;
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (component != null)
{
component.Dispose();
}
}
base.Dispose( disposing );
} private void timer1_Tick(object sender, EventArgs e)
{
KillMessageBox();
//停止计时器
((Timer)sender).Stop(); } private void StartKiller()
{
Timer timer = new Timer();
timer.Interval = 10000; //10秒启动
timer.Tick += new EventHandler(timer1_Tick);
timer.Start();
} private void KillMessageBox()
{
//查找MessageBox的弹出窗口,注意对应标题
IntPtr ptr = FindWindow(null,"MessageBox");
if(ptr != IntPtr.Zero)
{
//查找到窗口则关闭
PostMessage(ptr,WM_CLOSE,IntPtr.Zero,IntPtr.Zero);
}
}
在以下方法或属性之间的调用不明确:“setup.安装.FindWindow(string, string)”和“setup.安装.FindWindow(string, string)” D:\setup\setup\Form1.cs 240 26 setup为什么有一个错误?
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); public const int WM_CLOSE = 0x10; private System.ComponentModel.Container component = null;
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (component != null)
{
component.Dispose();
}
}
base.Dispose( disposing );
} private void timer1_Tick(object sender, EventArgs e)
{
KillMessageBox();
//停止计时器
((Timer)sender).Stop(); } private void StartKiller()
{
Timer timer = new Timer();
timer.Interval = 10000; //10秒启动
timer.Tick += new EventHandler(timer1_Tick);
timer.Start();
} private void KillMessageBox()
{
//查找MessageBox的弹出窗口,注意对应标题
IntPtr ptr = FindWindow(null,"MessageBox");
if(ptr != IntPtr.Zero)
{
//查找到窗口则关闭
PostMessage(ptr,WM_CLOSE,IntPtr.Zero,IntPtr.Zero);
}
}
在以下方法或属性之间的调用不明确:“setup.安装.FindWindow(string, string)”和“setup.安装.FindWindow(string, string)” D:\setup\setup\Form1.cs 240 26 setup为什么有一个错误?
{
if( disposing )
{
if (component != null)
{
component.Dispose();
}
}
base.Dispose( disposing );
}现在错误又变成这个了
错误 1 类型“setup.安装”已定义了一个名为“Dispose”的具有相同参数类型的成员 D:\setup\setup\Form1.cs 31 34 setup
http://tech.it168.com/d/2008-03-21/200803211724226.shtml