# WinBufToArray()

Copies data from a Windows memory buffer into a one-dimensional or two-dimensional array.

Member of the MccService class.

## Function Prototype

VB .NET

Copies data to a one-dimensional array of short values:

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

Copies data to a one-dimensional array of System.UInt16 values:

Public Function WinBufToArray(ByVal memHandle As IntPtr, ByVal dataArray As System.UInt16(), ByVal firstPoint As Integer, ByVal numPoints As Integer) As MccDaq.ErrorInfo

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

public ErrorInfo WinBufToArray(ByVal memHandle As IntPtr, ByVal dataArray As Double(,), ByVal firstPoint As Integer, ByVal numPoints As Integer, ByVal numChannels As Integer) As MccDaq.ErrorInfo

C# .NET

Copies data to a one-dimensional array of short values:

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

Copies data to a one-dimensional array of System.UInt16 values:

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

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

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

##### 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 to a one-dimensional array of short values:

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

Copies data to a one-dimensional array of System.UInt16 values:

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

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

public static ErrorInfo WinBufToArray(ByVal memHandle As Integer, ByRef dataArray As Double(,), ByVal firstPoint As Integer, ByVal numPoints As Integer, ByVal numChannels As Integer) As MccDaq.ErrorInfo

C# .NET

Copies data to a one-dimensional array of short values:

public static MccDaq.ErrorInfo WinBufToArray(int memHandle, out short dataArray, int firstPoint, int numPoints)

Copies data to a one-dimensional array of System.UInt16 values:

public static MccDaq.ErrorInfo WinBufToArray(int memHandle, out ushort dataArray, int firstPoint, int numPoints)

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

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

## Parameters

memHandle

This must be a memory handle that was returned by WinBufAllocEx() when the buffer was allocated. The data will be copied from this buffer

dataArray

The array that the data will be copied to. The first dimension should equal the number of channels. The second dimension should equal the number of points/channel.

firstPoint

Index of the first point in the memory buffer that data will be copied from.

numPoints

Number of data points to copy into dataArray.

numChannels

Number of channels to copy into dataArray.

## Returns

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

## Notes

- This method copies data from a Windows global memory buffer to a single value or into an array of doubles. This would typically be used to retrieve data from the buffer after executing an input scan method.
- You can use the firstPoint and numPoints parameters to copy only a portion of the buffer to the array. This can be useful if you want foreground code to manipulate previously collected data while a Background scan continues to collect new data.