Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OleLoadPicture error: Unknown error 0x800A01E1

579 views
Skip to first unread message

Jefferson Liu

unread,
Nov 13, 2002, 5:33:55 AM11/13/02
to
I write a function to use OleLoadPicture to get a picture from a url, i got
Unknown error 0x800A01E1. but Gdiplus::Image works.

void GetPictureFromUrl(LPCTSTR pszUrl)
{
pszUrl = "http://msdn.microsoft.com/msdnmag/images/covers/Dec02cover.gif";
CInternetSession session (_T("MyTest agent"), 1);
CStdioFile* pFile = NULL;
try
{
char szHead[] = "Accept: */*\r\n\r\n";
pFile = session.OpenURL (pszUrl, 1,
INTERNET_FLAG_RELOAD|INTERNET_FLAG_TRANSFER_BINARY, szHead, -1L);
CComPtr<IStream> pStm;
HRESULT hr = ::CreateStreamOnHGlobal(0, TRUE, &pStm);
ASSERT(SUCCEEDED(hr));
DWORD nSize = pFile->GetLength();
VOID* pbData = _alloca(nSize);
while(int n = pFile->Read(pbData, nSize))
{
ULONG dwWrite = 0;
hr = pStm->Write(pbData, n, &dwWrite);
ASSERT(SUCCEEDED(hr));
}

// ATL::CImage OK
CImage img;
hr = img.Load(pStm);
ASSERT(SUCCEEDED(hr));

// Gdiplus::Image OK
Image* pImage = Image::FromStream(pStm);
ASSERT(Ok==pImage->GetLastStatus());

// ERROR!
CComPtr<IPicture> pPic;
hr = OleLoadPicture(pStm, 0, FALSE, IID_IPicture, (void**)&pPic);
ASSERT(SUCCEEDED(hr));
}
catch (CInternetException *pEx)
{
ASSERT(0);
pEx->Delete();
}
if(pFile){
pFile->Close();
delete pFile;
}
session.Close();
}


Jefferson Liu

unread,
Nov 13, 2002, 9:23:27 PM11/13/02
to
problem fixed, before OleLoadPicture, seek to the beginning of the stream:

LARGE_INTEGER li;
li.QuadPart = 0;
hr = pStm->Seek(li, STREAM_SEEK_SET, NULL);


"Jefferson Liu" <jeffer...@sohu.com> wrote in message
news:eRZ78$viCHA.2232@tkmsftngp11...

0 new messages