Answered by:
Convert between IBuffer and Char*

Question
-
I want know how to convert form IBuffer to Char* And from Char* to IBuffer,waiting for the anwser:-)Friday, April 13, 2012 9:02 AM
Answers
-
The linked documentation includes the appropriate header files. You can use the IID_PPV_ARGS Macro for the query
IUnknown* pUnk = reinterpret_cast<IUnknown*>(buffer); IBufferByteAccess* pBufferByteAccess = nullptr; HRESULT hr = pUnk->QueryInterface(IID_PPV_ARGS(pBufferByteAccess);
--Rob
- Marked as answer by OceanCat Monday, April 16, 2012 5:13 AM
Sunday, April 15, 2012 6:20 PMModerator
All replies
-
To access the data in the buffer query the IBuffer for its IBufferByteAccess interface.
You can also read it out by loading it into a DataReader with DataReader.FromBuffer.
--Rob
- Proposed as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Friday, April 13, 2012 2:58 PM
Friday, April 13, 2012 2:58 PMModerator -
Saturday, April 14, 2012 7:03 AM
-
The linked documentation includes the appropriate header files. You can use the IID_PPV_ARGS Macro for the query
IUnknown* pUnk = reinterpret_cast<IUnknown*>(buffer); IBufferByteAccess* pBufferByteAccess = nullptr; HRESULT hr = pUnk->QueryInterface(IID_PPV_ARGS(pBufferByteAccess);
--Rob
- Marked as answer by OceanCat Monday, April 16, 2012 5:13 AM
Sunday, April 15, 2012 6:20 PMModerator -
This is the way to convert fro IBuffer to char*.
How to convert from char* to IBuffer?
Wednesday, April 18, 2012 12:06 PM -
You can copy the char* into the IBuffer with a DataWriter.
--Rob
Wednesday, April 18, 2012 11:44 PMModerator -
Can you please explain how that can be done?
What stream object should be used to initialize DataWriter (stream object)?
After it is initialized, then I should write it byte by byte?
Thanks.
Thursday, April 19, 2012 4:33 AM -
Sorry, my mistake. I got the DataWriter and DataReader capabilities mixed up.
To copy the char* in you'll have to get the Buffer with IBufferByteAccess .
Thursday, April 19, 2012 7:18 PMModerator -
Hii, Could you please give an illustrative example of convert from char* to IBuffer?
Thanks
- Edited by Vaibhavks Friday, September 28, 2012 6:36 AM
Friday, September 28, 2012 5:46 AM