110,534
社区成员
发帖
与我相关
我的任务
分享
using System.Runtime.InteropServices;
[DllImport("User32.dll")]
private static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);
private const int WM_CLOSE = 0x0010;
private void button1_Click(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_CLOSE, 0, 0);
}
public const int WM_CLOSE = 0x0010;
[DllImport("User32.dll")]
public static extern Int32 SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
//调用此代码即发送关闭消息到指定的窗口
public void SendCloseWindow(Form f)
{
SendMessage(f.Handle,WM_CLOSE,0,0);
}