SendMessage (coredll)
Last changed: -77.244.75.200

.
Summary
TODO - a short description

C# Signature:

[DllImport("User32.dll", EntryPoint="SendMessageW")]
static extern int SendMessageString(IntPtr hwnd, int wMsg, int wparam, int lparam);

VB Signature:

Declare Function SendMessage Lib "User32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr

Notes:

If you are searching for a way to send keys to an application, you can use System.Windows.Forms.SendKeys.Send(keys) after bringing the window to the top via the SetForegroundWindow API.

Tips & Tricks:

Sample Code:

[DllImport("User32.dll", EntryPoint="SendMessageW")]
static extern int SendMessage(IntPtr hwnd, int wMsg, int wparam, int lparam);

const int WM_CLOSE = 16;

private void button1_Click(object sender, System.EventArgs e)
{
    SendMessage(this.Handle, WM_CLOSE, 0, 0);
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
SendMessage on MSDN