I have an object that implements the interface Windows::Storage::Streams::IBuffer
, and I want to get an array of bytes out of it, however while looking at the d
As mentioned before, WindowsRuntimeBufferExtensions
from the namespace System::Runtime::InteropServices::WindowsRuntime
is only available for .Net applications and not for native C++ applications.
A possible solution would be to use Windows::Storage::Streams::DataReader
:
void process(Windows::Storage::Streams::IBuffer^ uselessBuffer)
{
Windows::Storage::Streams::DataReader^ uselessReader =
Windows::Storage::Streams::DataReader::FromBuffer(uselessBuffer);
Platform::Array<Byte>^ managedBytes =
ref new Platform::Array<Byte>(uselessBuffer->Length);
uselessReader->ReadBytes( managedBytes );
BYTE * bytes = new BYTE[uselessBuffer->Length];
for(int i = 0; i < uselessBuffer->Length; i++)
bytes[i] = managedBytes[i];
(...)
}