picName = 文件名
dc      = 目标设备句柄
w, h    = 目标设备句柄的 长和宽
**********************/
BOOL LoadPic(const char *picName, CDC &dc, DWORD w, DWORD h)
{
    IPicture *pPic;
    IStream *pStm;
    
    CFileStatus fstatus;
    CFile file;
    LONG cb;
    
    if (file.Open(picName,CFile::modeRead)&&
        file.GetStatus(picName, fstatus)&&
        ((cb = fstatus.m_size) != -1))
    {
        HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);
        LPVOID pvData = NULL;
        if (hGlobal != NULL)
        {
            if ((pvData = GlobalLock(hGlobal)) != NULL)
            {
                file.ReadHuge(pvData, cb);
                GlobalUnlock(hGlobal);
                CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
                
                if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic)))
                {
                    OLE_XSIZE_HIMETRIC hmWidth;
                    OLE_YSIZE_HIMETRIC hmHeight;
                    
                    pPic->get_Width(&hmWidth);
                    pPic->get_Height(&hmHeight);
                    
                    DWORD fX, fY;                    fX = (DWORD)((double)dc.GetDeviceCaps(HORZRES)*(double)hmWidth/
                         ((double)dc.GetDeviceCaps(HORZSIZE)*100.0) * 1.512f);
                    fY = (DWORD)((double)dc.GetDeviceCaps(VERTRES)*(double)hmHeight/
                         ((double)dc.GetDeviceCaps(VERTSIZE)*100.0) * 1.512f);                    DWORD top=0, left=0;
                    if (w!=0 && h!=0)
                    {
                        if (fX >= w)
                            fX = w;
                        else
                            left = (w-fX)/2;
                        if (fY >= h)
                            fY = h;
                        else
                            top = (h-fY)/2;
                    }
                    if(FAILED(pPic->Render(dc,left,top,fX,fY,0,hmHeight,hmWidth,-hmHeight,NULL)))
                    {
#ifdef _DEBUG
    TRACE("\nFailed To Render The picture!");
#endif
                        return FALSE;
                    }
                    pPic->Release(); 
                } 
                else
                {
#ifdef _DEBUG
    TRACE("\nError Loading Picture From Stream!");
#endif
                    return FALSE; 
                }
            }
        }
    }
    else
    {
#ifdef _DEBUG
    TRACE("\nCan't Open Image File!");
#endif
        return FALSE;
    }    return TRUE;
}
使用范例:
        CRect m_Rect;
        m_hPicView.GetWindowRect(&m_Rect);
        CDC *pDC=m_hPicView.GetDC();
//fn是文件名
    if (LoadPic(_T("fn.jpg"), *pDC, m_Rect.Width(), m_Rect.Height())==FALSE)

    if (LoadPic(fn, *pDC, m_Rect.Width(), m_Rect.Height())==FALSE)
 可以 读gif jpg bmp