类未注册 [英] Class not registered

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

问题描述

我正在通过Andrew W. Troelsen的Developer's Workshop to COM and ATL 3.0。

I'm working through "Developer's Workshop to COM and ATL 3.0" by Andrew W. Troelsen.

我试图在第3章中实现这个实验。

I'm trying to implement the lab in Chapter 3.

它显示了如何构建一个COM客户端来连接到一个早期实验室开发的inprocess COM服务器。

It shows you how to build a COM client to connect to an inprocess COM server that was developed in an earlier lab.

当我运行客户端时,当调用CoGetClassObject时,我收到错误类未注册。

When I run the client, I receive the error "Class not registered" when calling 'CoGetClassObject'.

这里是一段代码:

// Get the class factory pointer of CoCar.
hr = CoGetClassObject(CLSID_CoCar, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory, (void**)&pCF);

if(SUCCEEDED(hr))
{
    // Make a CoCar & get ICreateCar
    hr = pCF->CreateInstance(NULL, IID_ICreateCar, (void**)&pICreateCar);
    pCF->Release();
}
else
{
    char buff[100];
    BOOL bRet = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, buff, sizeof(buff), 0);
    std::cout << buff << std::endl;
}



我尝试通过合并以下.reg文件系统注册表:

I have tried to register the class by merging the following .reg file with the system registry:

REGEDIT
HKEY_CLASSES_ROOT\CarInProcServer.CoCar\CLSID = {EFC76CF8-71B8-477b-890A-1233BD9177CB}
HKEY_CLASSES_ROOT\CLSID\{EFC76CF8-71B8-477b-890A-1233BD9177CB} = CarInProcServer.CoCar
HKEY_CLASSES_ROOT\CLSID\{EFC76CF8-71B8-477b-890A-1233BD9177CB}
\InprocServer32 = C:\Users\Steven\Documents\Visual Studio 2005\Projects\CarInProcServer\release\CarInProcServer.dll

不确定这是否相关,但这里是我的.def文件:

Not sure if this is relevant, but here is my .def file:

LIBRARY "CarInProcServer"
EXPORTS
DllGetClassObject   @1  PRIVATE
DllCanUnloadNow     @2  PRIVATE

注意:我使用的是Windows 7

NB: I'm using Windows 7

任何人都可以帮助吗?

感谢

了解了!

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID {EFC76CF8-71B8-477b-890A-1233BD9177CB}
\InprocServer32 =C: \Users\Steven\Documents\Visual Studio 2005\Projects\CarInProcServer\release\CarInProcServer.dll

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID{EFC76CF8-71B8-477b-890A-1233BD9177CB} \InprocServer32 = "C:\Users\Steven\Documents\Visual Studio 2005\Projects\CarInProcServer\release\CarInProcServer.dll"

注册表。

似乎合并.reg文件与此条目在它没有工作。感谢肯白的帮助。 (和其他人提出解决方案)

It seems merging the .reg file with this entry in it did not work. Thanks to Ken White for his help. (and others who suggested solutions)

推荐答案

打开命令提示符,切换到DLL的文件夹,并运行regsvr32.exe: / p>

Open a command prompt, change to your DLL's folder, and run regsvr32.exe:

cd \Users\Steven\Documents\Visual Studio 2005\Projects\CarInProcServer\release 
regsvr32 CarInProcServer.dll

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

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