public const uint WM_SYSCOMMAND = 0x0112 ;
public const int SC_CLOSE = 61536 ;
[ DllImport ( "User32.DLL" )]
public static extern int SendMessage( IntPtr hWnd, uint Msg, int wParam, int lParam);
private void button1_Click( object sender , EventArgs e)
{
SendMessage(( IntPtr ) 12345 , WM_SYSCOMMAND, SC_CLOSE, 0 );
}