Skip to content

IGR_Extract_Subfile_Stream

IGR_Extract_Subfile_Stream extracts a sub-document to a stream from a compound document, given the ID of the sub-document.

The sub-document ID is obtained previously by IGR_Get_Subfile_Entry from the compound document, after being opened by IGR_Open_File or IGR_Open_Stream.

Prototype

IGR_LONG IGR_Extract_Subfile_Stream(
    IGR_LONG DocHandle,
    const IGR_UCS2* ID,
    IGR_Stream **Stream,
    Error_Control_Block* ISYSError);

Parameters

DocHandle: IGR_LONG

Handle to a document, opened by a call to IGR_Open_File, IGR_Open_File_Ex, IGR_Open_Stream or IGR_Open_Stream_Ex.

ID: Unicode string (UCS2)

Unique ID of the sub-document to be extracted, obtained by a call to IGR_Get_Subfile_Entry.

Stream: Pointer to an IGR_Stream pointer

A pointer to a system allocated memory stream will be returned.

It is the caller’s responsibility to free the stream object by calling

Stream->Close()

ISYSError: Pointer to Error_Control_Block

Returns error details if the call fails.

Return value

Success: IGR_LONG

Returns IGR_OK.

Failure: IGR_LONG

Returns one of the possible IGR_E error codes.

Sample code

Error_Control_Block ISYSError;
IGR_Stream *Stream;
IGR_UCS2 ID[4096], Name[1024];
INT64 FileDate, FileSize;

while (true)
{
    IGR_LONG rc = IGR_Get_Subfile_Entry(DocHandle, ID, Name, &FileDate, &FileSize,
                &ISYSError);
    if (rc != IGR_OK)
    {
        if (rc != IGR_NO_MORE)
            // ReportError(rc);
        break;
    }
    rc = IGR_Extract_Subfile_Stream(DocHandle, ID, &Stream, &ISYSError);
    if (rc != IGR_OK)
        // ReportError(rc);
    else
        // DoSomethingWithTheStream(Stream);
    Stream->close();
}

See also