Export (0) Print
Expand All
Expand Minimize

MsiRecordReadStream function

The MsiRecordReadStream function reads bytes from a record stream field into a buffer.

Syntax


UINT MsiRecordReadStream(
  _In_     MSIHANDLE hRecord,
  _In_     UINT iField,
  _Out_    char *szDataBuf,
  _Inout_  DWORD *pcbDataBuf
);

Parameters

hRecord [in]

Handle to the record.

iField [in]

Specifies the field of the record.

szDataBuf [out]

A buffer to receive the stream field. You should ensure the destination buffer is the same size or larger than the source buffer. See the Remarks section.

pcbDataBuf [in, out]

Specifies the in and out buffer count. On input, this is the full size of the buffer. On output, this is the number of bytes that were actually written to the buffer. See the Remarks section.

Return value

ERROR_INVALID_DATATYPE

The field is not a stream column.

ERROR_INVALID_HANDLE

An invalid or inactive handle was supplied.

ERROR_INVALID_PARAMETER

An invalid parameter was passed to the function.

ERROR_SUCCESS

The function succeeded.

Remarks

To read a stream, set pcbDataBuf to the number of bytes that are to be transferred from stream to buffer each time the function is called. On return, the MsiRecordReadStream resets pcbDataBuf to the number of bytes that were actually transferred. If the buffer is smaller than the stream, the stream is repositioned when the buffer becomes full such that the next data in the stream is transferred by the next call to the function. When no more bytes are available, MsiRecordReadStream returns ERROR_SUCCESS.

If you pass 0 for szDataBuf then pcbDataBuf is reset to the number of bytes in the stream remaining to be read.

The following code sample reads from a stream that is in field 1 of a record specified by hRecord and reads the entire stream 8 bytes at a time.


char szBuffer[8];
PMSIHANDLE hRecord;
DWORD cbBuf = sizeof(szBuffer);
do 
{
    if (MsiRecordReadStream(hRecord, 1, szBuffer, 
        &cbBuf) != ERROR_SUCCESS)
        break; /* error */
}
while (cbBuf == 8);  //continue reading the stream while you receive a full buffer
//cbBuf will be less once you reach the end of the stream and cannot fill your 
//buffer with stream data


See also OLE Limitations on Streams.

Requirements

Version

Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP

Header

Msiquery.h

Library

Msi.lib

DLL

Msi.dll

See also

Record Processing Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft