Thank you steve,
.then([=](pplx::task<http_response> response)
.then([=](pplx::task<http_response> response)
{
try{ http_response response1 = response.get();
std::cout << "\n" << "statuscode:";
std::cout << response1.status_code();
std::cout << "\n" << "response body: ";
ucout << response1.to_string();
container_buffer<std::vector<uint8_t>> container;
response1.body().read_to_end(container);
std::vector<uint8_t> body = std::move(container.collection());
std::cout << "\n ***************";
std::cout<<container.size();
DWORD length = container.size();
IStream *m_pStream;
HGLOBAL hMem;
LPVOID pData = NULL;
hMem = GlobalAlloc(GMEM_MOVEABLE, length);
pData = GlobalLock(hMem);
memmove(pData, &body, length); //application crash here with memmove or memcpy
GlobalUnlock(hMem);
std::cout << "done";
HRESULT hr = CreateStreamOnHGlobal(hMem, TRUE, &m_pStream);
if (hr == S_OK)
{
std::cout << "done";
}
}
catch (const http_exception &e)
{
std::cout << "error";
}
}).wait();
I tried the code you provided me, but my application just crash at memcpy or memmove !