locked
IBufferByteAccess namespace

    Question

  • I'm seeing that it is recommended to use IBufferByteAccess to access the data in an IBuffer object.  What namespace is this interface defined in?  Can I just cast from IBuffer to IBufferByteAccess like I could with other interfaces?
    Tuesday, October 16, 2012 4:31 PM

Answers

  • IBufferByteAccess is a COM interface. You need to cast your IBuffer to an IUnknown and then query for IBufferByteAccess:

    IUnknown* pUnk = reinterpret_cast<IUnknown*>(buffer);
    	
    IBufferByteAccess* pBufferByteAccess = nullptr;
    HRESULT hr = pUnk->QueryInterface(IID_PPV_ARGS(pBufferByteAccess);

    Depending on what you are doing with the buffer you may also be able to access it with a DataReader (see DataReader::FromBuffer) or DataWriter (see DataWriter::WriteBuffer).

    --Rob

    • Marked as answer by Jesse Jiang Monday, October 22, 2012 5:58 AM
    Wednesday, October 17, 2012 12:00 AM
    Owner

All replies

  • Windows::Storage::Streams::

    rob qqq

    Tuesday, October 16, 2012 6:45 PM
  • IBuffer is defined in Windows::Storage::Streams, but I do not believe that IBufferByteAccess is.  If it is, what assembly do I have to reference to use it?
    Tuesday, October 16, 2012 7:25 PM
  • IBufferByteAccess is a COM interface. You need to cast your IBuffer to an IUnknown and then query for IBufferByteAccess:

    IUnknown* pUnk = reinterpret_cast<IUnknown*>(buffer);
    	
    IBufferByteAccess* pBufferByteAccess = nullptr;
    HRESULT hr = pUnk->QueryInterface(IID_PPV_ARGS(pBufferByteAccess);

    Depending on what you are doing with the buffer you may also be able to access it with a DataReader (see DataReader::FromBuffer) or DataWriter (see DataWriter::WriteBuffer).

    --Rob

    • Marked as answer by Jesse Jiang Monday, October 22, 2012 5:58 AM
    Wednesday, October 17, 2012 12:00 AM
    Owner
  • it is. here is my use case.

     Microsoft::WRL::ComPtr< Windows::Storage::Streams::IBufferByteAccess > buffer_byte_access;

    reinterpret_cast< IUnknown* >( read_buffer )->QueryInterface( IID_PPV_ARGS( &buffer_byte_access ) ) ;

    you need #include <robuffer.h>


    rob qqq

    • Proposed as answer by Chris Guzak Thursday, October 18, 2012 6:44 AM
    Wednesday, October 17, 2012 11:34 PM