Transfer data in synchronous mode using function UsbTransfer is rather simple but it blocks calling thread execution until transfer completes. The following is an example of blocking transfer assuming that all handles are opened. Error checks are omitted. For extended information about synchronous transfer refer to 'Pipes' example.
ULONG BufferLength, BytesReturned;
// Open first RapidUSB device
hUsb = OpenRapidUsb(0);
// Open first RapidUSB device pipe
hPipe = UsbPipeOpen(hUsb, 0);
// Allocate transfer buffer
pBuffer = malloc(BufferLength);
// Start transfer...
BOOL success = UsbTransfer(hPipe, pBuffer, BufferLength, &BytesReturned);
// thread waits transfer operation to finish
if ( success)
// Transfer successful...
// Transfer failed....