为什么调用findwindow说在以下方法或属性之间的调用不明确?

dennisberg1234 2012-05-15 02:54:32
 [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

为什么有一个错误?
...全文
453 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhujiawei7 2012-05-15
  • 打赏
  • 举报
回复
重写、重命名不就行了
dennisberg1234 2012-05-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

Dispose( bool disposing )重复定义了呗
[/Quote]
是更具这个网页上的来的
http://tech.it168.com/d/2008-03-21/200803211724226.shtml
dennisberg1234 2012-05-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

Dispose( bool disposing )重复定义了呗
[/Quote]
那该怎么改?就是想做一个messagebox自动关闭的效果
zhujiawei7 2012-05-15
  • 打赏
  • 举报
回复
Dispose( bool disposing )重复定义了呗
bdmh 2012-05-15
  • 打赏
  • 举报
回复
你搜一下,肯定再把别的地方还有 FindWindow的声明,因为是static声明,和可能导致了两个地方的 FindWindow都可以访问,编译器识别不了
dennisberg1234 2012-05-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

public extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[/Quote]
 protected override void Dispose( bool disposing )
{
if( disposing )
{
if (component != null)
{
component.Dispose();
}
}
base.Dispose( disposing );
}


现在错误又变成这个了。。。
错误 1 类型“setup.安装”已定义了一个名为“Dispose”的具有相同参数类型的成员 D:\setup\setup\Form1.cs 31 34 setup
EnForGrass 2012-05-15
  • 打赏
  • 举报
回复
public extern static IntPtr FindWindow(string lpClassName, string lpWindowName);

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧