# cbWinBufToArray32()

Copies 32-bit data from a Windows memory buffer into an array.

## Function Prototype

C/C++

int cbWinBufToArray32(int MemHandle, unsigned long* DataArray, long FirstPoint, long Count)

Visual Basic

Function cbWinBufToArray32(ByVal MemHandle&, DataArray&, ByVal FirstPoint&, ByVal Count&) As Long

## Arguments

MemHandle

The memory handle that was returned by cbWinBufAlloc32() when the buffer was allocated. The buffer should contain the data that you want to copy.

DataArray

The array that the data is copied to.

FirstPoint

The index of the first point in the memory buffer that data is copied from.

Count

The number of data points to copy.

## Returns

- Error code or zero if no errors.

## Notes

- You can copy only a portion of the buffer to the array using the FirstPoint and Count argument. This is useful if you want foreground code to manipulate previously collected data while a BACKGROUND scan continues to collect new data.
- Although this function is available to Windows C programs, it is not necessary, since you can manipulate the memory buffer directly by casting the MemHandle returned from cbWinBufAlloc32() to the appropriate type. This method avoids having to copy the data from the memory buffer to an array.

Refer to the following example:

/*declare and initialize the variables*/
long Count = 1000;
unsigned short *DataArray = NULL;
int MemHandle = 0;
/*allocate the buffer and cast it to a pointer to an unsigned long*/
MemHandle = cbWinBufAlloc32(Count);
DataArray = (unsigned long*)MemHandle;
/*scan in the data*/
cbCInScan(......,MemHandle,...);
/*print the results*/
for(int i=0; i<Count; ++i)

printf("Data[%d]=%d\n", i, DataArray[i]);

/*free the buffer and NULL the pointer*/
cbWinBufFree(MemHandle);
DataArray = NULL;