[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为什么有一个错误?

解决方案 »

  1.   

    public extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
      

  2.   

     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
      

  3.   

    你搜一下,肯定再把别的地方还有 FindWindow的声明,因为是static声明,和可能导致了两个地方的 FindWindow都可以访问,编译器识别不了
      

  4.   

    Dispose( bool disposing )重复定义了呗
      

  5.   

    那该怎么改?就是想做一个messagebox自动关闭的效果
      

  6.   

    是更具这个网页上的来的
    http://tech.it168.com/d/2008-03-21/200803211724226.shtml