keybd_event (coredll)
Last changed: -193.128.116.98

.
Summary
The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function (from msdn.microsoft.com)

C# Signature:

[DllImport("coredll.dll", EntryPoint="keybd_event", SetLastError=true)]
internal static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

VB Signature:

Declare Sub keybd_event Lib "coredll.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Taken from openNetCF in OpenNETCF.Win32.Core

Tips & Tricks:

Please add some!

Sample Code:

//This sample code is mainly used to turn the backlight on a WM device. The keystrokes can changed to use for other functions

    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;

    namespace Win32
    {
    public static class CoreDLL
    {
        [DllImport("coredll.dll", EntryPoint = "keybd_event", SetLastError = true)]
        public static extern void keybd_event
        (
        byte bVk,
        byte bScan,
        int dwFlags,
        int dwExtraInfo
        );

        //To call the key stroke to turn on the Backlight.
        keybd_event(01, 01, 1, 1);
    }
    }

Documentation
keybd_event on MSDN