# WinBufToArray32()

Copies 32-bit data from a Windows global memory buffer into a one-dimensional or two-dimensional array. This method is typically used to retrieve data from the buffer after executing an input scan method.

Member of the MccService class.

## Function Prototype

VB .NET

Copies data into a two-dimensional array of double values:

Public Shared Function WinBufToArray32(ByVal memHandle As IntPtr, ByVal dataArray(,) As Double, ByVal firstPoint As Integer, ByVal numPoints As Integer, ByVal numChannels As Integer) As MccDaq.ErrorInfo

Copies data into an array of integer values:

Public Shared Function WinBufToArray32(ByVal memHandle As IntPtr, ByVal dataArray As Integer(), ByVal firstPoint As Integer, ByVal numPoints As Integer) As MccDaq.ErrorInfo

Copies data into an array of System.UInt32 values:

Public Shared Function WinBufToArray32(ByVal memHandle As IntPtr, ByVal dataArray As System.UInt32(), ByVal firstPoint As Integer, ByVal numPoints As Integer) As MccDaq.ErrorInfo

C# .NET

Copies data into a two-dimensional array of double values:

public static MccDaq.ErrorInfo WinBufToArray32(IntPtr memHandle, double[,] dataArray, int firstPoint, int numPoints, int numChannels)

Copies data into an array of integer values:

public MccDaq.ErrorInfo WinBufToArray32(IntPtr memHandle, int[] dataArray, int firstPoint, int numPoints)

Copies data into an array of System.UInt32 values:

public MccDaq.ErrorInfo WinBufToArray32(int memHandle, uint[] dataArray, int firstPoint, int numPoints)

##### Deprecated methods

The following methods are deprecated, and should only be used for legacy applications. The methods above are preferred, and must be used for 64-bit application development.

VB .NET

Copies data into a two-dimensional array of double values:

Public Shared Function WinBufToArray32(ByVal memHandle As Integer, ByRef dataArray(,) As Double, ByVal firstPoint As Integer, ByVal numPoints As Integer, ByVal numChannels As Integer) As MccDaq.ErrorInfo

Copies data into an array of integer values:

Public Shared Function WinBufToArray32(ByVal memHandle As Integer, ByRef dataArray As Integer, ByVal firstPoint As Integer, ByVal numPoints As Integer) As MccDaq.ErrorInfo

Copies data into an array of System.UInt32 values:

Public Shared Function WinBufToArray32(ByVal memHandle As Integer, ByRef dataArray As System.UInt32, ByVal firstPoint As Integer, ByVal numPoints As Integer) As MccDaq.ErrorInfo

C# .NET

Copies data into a two-dimensional array of double values:

public MccDaq.ErrorInfo WinBufToArray32(int memHandle, out double[,] dataArray, int firstPoint, int numPoints, int numChannels)

Copies data into an array of integer values:

public MccDaq.ErrorInfo WinBufToArray32(int memHandle, out int dataArray, int firstPoint, int numPoints)

Copies data into an array of System.UInt32 values:

public MccDaq.ErrorInfo WinBufToArray32(int memHandle, out uint dataArray, int firstPoint, int numPoints)

## Parameters

memHandle

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

dataArray

The array where the data is copied.

firstPoint

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

numPoints

The number of data points to copy.

numChannels

The number of channels to copy into dataArray.

## Returns

- An ErrorInfo object that indicates the status of the operation.

## Notes

- You can copy only a portion of the buffer to the array using the firstPoint and numPoints 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 method is available to Windows C programs, it is not necessary, since you can manipulate the memory buffer directly by casting the MemHandle returned from WinBufAlloc32() 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 numPoints= 1000;
unsigned short *dataArray = NULL;
int MemHandle = 0;
/*allocate the buffer and cast it to a pointer to an unsigned long*/
MemHandle = WinBufAlloc32(numPoints);
dataArray = (unsigned long*)MemHandle;
/*scan in the data*/
CInScan(......,MemHandle,...);
/*print the results*/
for(int i=0; i<numPoints; ++i)

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

/*free the buffer and NULL the pointer*/
WinBufFree(MemHandle);
dataArray = NULL;