|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
CInternetSession session;
CFile *Pfile;
IStream *pStm;
DWORD dwFileSize,dwByteRead;
CString url(_T("http://news.baidu.com/z/resource/r/image/2014-02-12/5f6684219f4cf8280bc943311699e4ef.jpg"));
Pfile=session.OpenURL(url,1,INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE);
if (Pfile!=INVALID_HANDLE_VALUE)
{
dwFileSize= Pfile->GetLength();//获取文件字节数
if (dwFileSize==0xFFFFFFFF)
{
MessageBox(L"图片获取失败!");
}
}
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
LPVOID pvData = NULL;
pvData = GlobalLock(hGlobal);
dwByteRead = Pfile->Read(pvData,dwFileSize);
GlobalUnlock(hGlobal);
CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
Gdiplus::Bitmap bmp(pStm);
HBITMAP hBitmap;
session.Close();
bmp.GetHBITMAP(Gdiplus::Color(0,0,0), &hBitmap);
bmp.GetLastStatus();
if (::OpenClipboard(NULL))
{
MessageBox(_T("走这里了"));
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, hBitmap);
::CloseClipboard();
}
|
|