无法找到user32.dll
[DllImport("User32", CharSet = CharSet.Auto)]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("User32", CharSet = CharSet.Auto)]
public static extern int PostMessage(IntPtr hwd, int msg, IntPtr wparam, IntPtr lParma);// 这是user32外部导入
public const int WM_CLOSE = 0x10;
private void btnShow_Click(object sender, EventArgs e)
{
System.Windows.Forms.Timer setTimer = new System.Windows.Forms.Timer();
setTimer.Interval = (2000);
setTimer.Tick += new EventHandler(setTimer_Tick);
setTimer.Enabled = true;
setTimer.Start();
MessageBox.Show("2秒后关闭", "自动关闭");
}
void setTimer_Tick(object sender, EventArgs e)
{
KillMessageBox();
((System.Windows.Forms.Timer)sender).Stop();
}
void KillMessageBox()
{
IntPtr ptr = FindWindow(null, "自动关闭");//执行到这里 无法找到user32
if (ptr != IntPtr.Zero)
PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
怎样才能获得user32.dll
------解决方案--------------------[DllImport("User32.dll", CharSet = CharSet.Auto)]
------解决方案--------------------百度一下,自己下载!
------解决方案--------------------好像是user32.dll
------解决方案--------------------[DllImport("user32.dll", CharSet = CharSet.Auto)]