GetRawInputBuffer function (winuser.h)

Performs a buffered read of the raw input messages data found in the calling thread's message queue.

Syntax

UINT GetRawInputBuffer(
  [out, optional] PRAWINPUT pData,
  [in, out]       PUINT     pcbSize,
  [in]            UINT      cbSizeHeader
);

Parameters

[out, optional] pData

Type: PRAWINPUT

A pointer to a buffer of RAWINPUT structures that contain the raw input data. If NULL, size of the first raw input message data (minimum required buffer), in bytes, is returned in *pcbSize.

[in, out] pcbSize

Type: PUINT

The size, in bytes, of the provided RAWINPUT buffer.

[in] cbSizeHeader

Type: UINT

The size, in bytes, of the RAWINPUTHEADER structure.

Return value

Type: UINT

If pData is NULL and the function is successful, the return value is zero. If pData is not NULL and the function is successful, the return value is the number of RAWINPUT structures written to pData.

If an error occurs, the return value is (UINT)-1. Call GetLastError for the error code.

Remarks

When an application receives raw input, its message queue gets a WM_INPUT message and the queue status flag QS_RAWINPUT is set.

Using GetRawInputBuffer, the raw input data is read in the array of variable size RAWINPUT structures and corresponding WM_INPUT messages are removed from the calling thread's message queue. You can call this method several times with buffer that cannot fit all message's data until all raw input messages have been read.

The NEXTRAWINPUTBLOCK macro allows an application to traverse an array of RAWINPUT structures.

If all raw input messages have been successfully read from message queue then QS_RAWINPUT flag is cleared from the calling thread's message queue status.

Note

WOW64: To get the correct size of the raw input buffer, do not use *pcbSize, use *pcbSize * 8 instead. To ensure GetRawInputBuffer behaves properly on WOW64, you must align the RAWINPUT structure by 8 bytes. The following code shows how to align RAWINPUT for WOW64.

[StructLayout(LayoutKind.Explicit)]
internal struct RAWINPUT
{
    [FieldOffset(0)]
    public RAWINPUTHEADER header;

    [FieldOffset(16+8)]
    public RAWMOUSE mouse;

    [FieldOffset(16+8)]
    public RAWKEYBOARD keyboard;

    [FieldOffset(16+8)]
    public RAWHID hid;
}

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also

Conceptual

GetMessage

NEXTRAWINPUTBLOCK

RAWINPUT

RAWINPUTHEADER

Raw Input

Reference

About Raw Input