日期:2014-05-18  浏览次数:20863 次

为什么调用findwindow说在以下方法或属性之间的调用不明确?
C# code
 [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

为什么有一个错误?


------解决方案--------------------
public extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
------解决方案--------------------
重写、重命名不就行了