GetRawInputBuffer function

Performs a buffered read of the raw input data.

Syntax

UINT GetRawInputBuffer(
  PRAWINPUT pData,
  PUINT     pcbSize,
  UINT      cbSizeHeader
);

Parameters

pData

Type: PRAWINPUT

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

pcbSize

Type: PUINT

The size, in bytes, of a RAWINPUT structure.

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

Using GetRawInputBuffer, the raw input data is buffered in the array of RAWINPUT structures. For an unbuffered read, use the GetMessage function to read in the raw input data.

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

Note  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