destroywindow (user32)
Last changed: ksgfk-176.122.161.184

.
Summary
Destroys the specified window.

C# Signature:

[DllImport("user32.dll")]
static extern bool DestroyWindow(IntPtr hWnd);

VB Signature:

Declare Function DestroyWindow Lib "user32.dll" (hWnd As IntPtr) As Boolean

Notes:

hWnd is the pointer to the window you want to close/destroy. Create a new IntPtr object with the window's handle as a parameter to it's constructor. Make sure the pointers are in decimal, not in hex as spy++ gives them to you.

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("user32.dll")]

static extern bool DestroyWindow(IntPtr hWnd);

//Closes the form

btnCloseWindow_Click(object sender, EventArgs e)

{

    DestroyWindow(this.Handle)    

}

Alternative Managed API:

System.Windows.Forms.Form.Close

Documentation