类未在MFC DLL中注册 [英] Class Not Registered in MFC dll

查看:84
本文介绍了类未在MFC DLL中注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我正在研究基于MFC对话的应用程序,因为我在COM中使用了Dll功能。 DLL已成功构建。我使用GUID为dll应用程序中的接口注册了注册表编辑器。我在下面编写了初始化com对象的代码,但它给出了未注册类。我也复制了.reg文件的代码。的错误。

//////////////基于对话的应用代码////////////////////

 ISum * pISum = NULL; 
< pre < span class =code-attribute> lang = cs > HRESULT hr = CoInitialize(NULL);
if(FAILED(hr))
{
AfxMessageBox(L& quot; Com库无法初始化& quot; MB_ICONERROR);
返回FALSE;
}
hr = CoCreateInstance(CLSID_SumSubtract,NULL,CLSCTX_INPROC_SERVER,IID_ISum,( void **)& amp; pISum);
if(FAILED(hr))
{
AfxMessageBox(L& quot; ISeum Int)无法获得表面& quot;,MB_ICONERROR);
返回FALSE;
} < / pre >





////////。文件代码//////////// ////

 REGEDIT4 
[HKEY_CLASSES_ROOT\CLSID\ {996BA870-10DF-44f3-81C1-3C9332ADFE35}]
@ = ClassFactoryMFC
[HKEY_CLASSES_ROOT\CLSID\ {996BA870-10DF-44f3-81C1 -3C9332ADFE35} \ InProcServer32]
@ = C:\\Windows\\System32 \\ClassFactoryMFC.dll





请给我解决方案!!!

解决方案

你应该使用 Regsvr32 [ ^ ]正确注册COM库。

Hello!
I am working on MFC dialogue based application,for that I used Dll functionality in COM. DLL is build successfully. I register it with registry editor by using GUID for the interfaces in dll application.I wrote below code for Initialise com object,but it gives error that "Class Not Registered.I also copy the code of my .reg file.
//////////////Dialogue based application code////////////////////

ISum *pISum=NULL;
<pre lang="cs">HRESULT hr=CoInitialize(NULL);
    if(FAILED(hr))
    {
        AfxMessageBox(L&quot;Com Library cannot initialized&quot;,MB_ICONERROR);
        return FALSE;
    }
    hr=CoCreateInstance(CLSID_SumSubtract,NULL,CLSCTX_INPROC_SERVER,IID_ISum,(void **)&amp;pISum);
    if(FAILED(hr))
    {
        AfxMessageBox(L&quot;ISeum Interface cannot be obtained&quot;,MB_ICONERROR);
        return FALSE;
    }</pre>



////////.Reg file code////////////////

REGEDIT4
[HKEY_CLASSES_ROOT\CLSID\{996BA870-10DF-44f3-81C1-3C9332ADFE35}]
@="ClassFactoryMFC"
[HKEY_CLASSES_ROOT\CLSID\{996BA870-10DF-44f3-81C1-3C9332ADFE35}\InProcServer32]
@=C:\\Windows\\System32\\ClassFactoryMFC.dll"



Please give me solution!!!

解决方案

You should use Regsvr32[^] to register COM libraries properly.


这篇关于类未在MFC DLL中注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆