Platform SDK: DirectX |
This topic pertains only to applications written in Visual Basic.
A few DirectX methods return data in parameters whose type is unspecified. For instance, the DirectSoundCaptureBuffer.ReadBuffer method takes a buffer parameter of type Any.
Typically you will want such methods to return their data as an array of bytes. Because Visual Basic arrays have extra information before the actual data, you cannot simply pass the name of the array to the method. Instead, you must pass the first element of the array, as in the following example, where dsCaptureBuffer is a DirectSoundCaptureBuffer object, buffer is a zero-based array of bytes, and nBytes is a Long containing the number of bytes to be read:
ReDim buffer(nBytes) Call dsCaptureBuffer.ReadBuffer(0, nBytes, buffer(0), 0)
Note, however, that some methods do take an actual typed array as a parameter. (See, for example, DirectInputDevice.SetDataFormat.) In such cases you must pass in the array itself rather than its first element, as in the following example, where formatArray is an array of DIOBJECTDATAFORMAT types.
MyDevice.SetDataFormat(diDataFormat, formatArray())