没有注册类的怪事
用了腾讯的一个DLL(ImageOle.dll)实现RichEdit插入图片(.bmp,.gif等格式)的功能,前一段时间,能正常工作.但最近我发现却不能显示图片了,弹出“没有注册类”的MessageBox.
void CExtRichEdit::InsertFace(CString strPicPath)
{
LPLOCKBYTES lpLockBytes = NULL;
SCODE sc;
HRESULT hr;
//print to RichEdit' s IClientSite
LPOLECLIENTSITE m_lpClientSite;
//A smart point to IAnimator
IGifAnimatorPtr m_lpAnimator;
//ptr 2 storage
LPSTORAGE m_lpStorage;
//the object 2 b insert 2
LPOLEOBJECT m_lpObject;
//Create lockbytes
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpLockBytes != NULL);
//use lockbytes to create storage
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &m_lpStorage);
if (sc != S_OK)
{
VERIFY(lpLockBytes->Release() == 0);
lpLockBytes = NULL;
AfxThrowOleException(sc);
}
ASSERT(m_lpStorage != NULL);
//get the ClientSite of the very RichEditCtrl
GetIRichEditOle()->GetClientSite(&m_lpClientSite);
ASSERT(m_lpClientSite != NULL);
try
{
//Initlize COM interface
hr = ::CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
if( FAILED(hr) )
_com_issue_error(hr);
//Get GifAnimator object
//here, I used a smart point, so I do not need to free it
hr = m_lpAnimator.CreateInstance(CLSID_GifAnimator);//!!!!!!!!!!!!!!!
if( FAILED(hr) )
_com_issue_error(hr);
//还有其他的代码,省略......................
}
断点跟踪到我打的感叹号那里后就抛出异常了!!!!!!!!!
catch( _com_error e )//抛出没有注册类
{
AfxMessageBox(e.ErrorMessage());
::CoUninitialize();
}
目前我不知道到底是哪一个类没有被注册......
求各位高手帮忙看看,困惑了我很多时日了.....
解决问题后,拜谢,分立马送上....