我还是把我的代码贴出来吧 希望高人看下 指点哪里有错[code]
void CFinalDlg::OnButton1()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_EDIT2)->GetWindowText(m_edit2);
CppSQLite3DB db;
db.open(L"\\Fab\\mySqlite.db");
CppSQLite3Query q = db.execQuery(L"select * from Address_List where ID ='"+m_edit2+"'");
CString strTemp1;
while (!q.eof())
{
strTemp1.Format(L"%s",q.fieldValue(7));
q.nextRow();
}
q.finalize(); //以上为首先从数据库中查询出符合条件的路径strTemp1,根据调试结果,到这是可以的。
IImagingFactory *pImgFactory = NULL; //往下是查到的显示图片的代码
IImage *pImage = NULL;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
HBITMAP hResult = 0;
if (SUCCEEDED(CoCreateInstance (CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **)&pImgFactory)))
{
if (SUCCEEDED(pImgFactory->CreateImageFromFile(strTemp1, &pImage)))
{
//CWindowDC dc(0);
CPaintDC dc(this);
CDC dcBitmap;
dcBitmap.CreateCompatibleDC(&dc);
hResult = CreateCompatibleBitmap(dc.GetSafeHdc(), 200, 200);
if (hResult)
{
HGDIOBJ hOldBitmap = dcBitmap.SelectObject(hResult);
//pImage->GetThumbnail(0,0,&pImage);
pImage->Draw(dc.GetSafeHdc(), CRect(0, 0, 200, 200), NULL);
dcBitmap.SelectObject(hOldBitmap);
}
pImage->Release();
}
pImgFactory->Release();
}
CoUninitialize();
}