IStream的Read和write使用

String^ postData = ref new String(L"vps=1%23android2.2%23sdk%23JS11332819623969119164175006%23128%23480_800%237.1.3&pver=5&funid=4001");

ULONG BytesWritten = 0;
ComPtr<IStream> postStream;

HRESULT hr = S_FALSE;
CreateStreamOnHGlobal(nullptr,true,&postStream);
const wchar_t *pBuf = postData->Data();
int wlen = 2*(postData->Length()+1);
postStream->Write((void*) pBuf, wlen, &BytesWritten);

ULONG uLongRet;
LARGE_INTEGER move;
move.QuadPart = 0;
postStream->Seek(move, STREAM_SEEK_SET, NULL);
wchar_t* pRet = NULL;
pRet = new wchar_t[wlen];
postStream->Read((void*) pRet, BytesWritten, &uLongRet);

posted @ 2012-07-03 13:31  狼哥2  阅读(5274)  评论(0编辑  收藏  举报