Export (0) Print
Expand All

GetRawInputBuffer function

Performs a buffered read of the raw input data.

Syntax


UINT WINAPI GetRawInputBuffer(
  _Out_opt_ PRAWINPUT pData,
  _Inout_   PUINT     pcbSize,
  _In_      UINT      cbSizeHeader
);

Parameters

pData [out, optional]

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 [in, out]

Type: PUINT

The size, in bytes, of a RAWINPUT structure.

cbSizeHeader [in]

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]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
GetMessage
RAWINPUT
RAWINPUTHEADER
NEXTRAWINPUTBLOCK
Conceptual
Raw Input

 

 

Community Additions

ADD
Show:
© 2015 Microsoft