实现COM接口C++ / VC++ 6.0/MFC
入门级程序员正在尝试实现 COM 接口。我正在开发一个与 Aloha 销售点系统交互的程序。 Aloha 使用 COM 与外部程序一起工作。我正在尝试从磁卡读卡器拦截卡数据,该读卡器是 OPOS 读卡器,而不是键盘楔子。我拥有的文档没有解释如何实现这个特定的接口,但它确实解释了如何实现类似的接口。我试图遵循这个例子,但我一无所获。 Aloha 的支持是不存在的,他们的文档很差、过时,有时甚至是错误的,即使我已经支付了许可证费用。
我尝试制作一个简单的应用程序只是为了测试此功能。这是我所做的:
1)使用 ATL COM 应用程序向导在 vc++ 6.0 中创建一个新项目 2)服务器类型dll 3)插入新的atl对象->简单的物体 4)右键单击我的新类并选择实现接口 5)浏览类型库,选择Iber.tlb(Aloha的tlb) 6)选择我想要实现的接口
,制作了.h、.cpp和.rgs文件。
.h 文件包含:
public:
// IInterceptMagcard
STDMETHOD(InterceptMagcard)(BSTR bstrAccountNumber, BSTR bstrCustomerName, BSTR bstrExpirationDate, BSTR bstrTrack1Info, BSTR bstrTrack2Info, BSTR bstrTrack3Info, BSTR bstrRawMagcardData, LONG * bWasDataHandled)
{
if (bWasDataHandled == NULL)
return E_POINTER;
return E_NOTIMPL;
}
这是我实现代码的地方吗?我在那里放了一些测试代码,写入 txt 文件只是为了测试它。然后我使用:
HRESULT hr = CoCreateInstance(CLSID_AlohaMag, NULL, CLSCTX_INPROC_SERVER,
IID_IAlohaMag, (void **) &g_pIInterceptMagcard);
其中 g_pIInterceptMagcard 是指向使用上面的向导创建的接口类的指针。
当我尝试注册时,我收到以下 HRESULT:0x80040112 即“未获得使用许可的类别”。
这是否意味着我的程序没有创建必要的注册表项?
Entry level programmer here trying to implement a COM interface. I am working on a program that interfaces with the Aloha point of sale system. Aloha uses COM to work with external programs. I am trying to intercept card data from the mag card reader, which is an OPOS reader, not a keyboard wedge. The documentation I have doesn't explain how to implement this particular interface, but it does explain how to implement a similar one. I have tried to follow this example but I am getting no where. Support from Aloha is non-existent, their documentation is poor, outdated and sometimes just wrong, even though I have paid for a license.
I tried to make a simple app just to test this functionality. Here is what I did:
1) create a new project in vc++ 6.0 using ATL COM app wizard
2) server type dll
3) insert new atl object -> simple object
4) right click on my new class and choose implement interface
5) browse for type library, chose Iber.tlb (Aloha's tlb)
6) chose the interface I want to implement
That made a .h, .cpp and .rgs file.
The .h file has:
public:
// IInterceptMagcard
STDMETHOD(InterceptMagcard)(BSTR bstrAccountNumber, BSTR bstrCustomerName, BSTR bstrExpirationDate, BSTR bstrTrack1Info, BSTR bstrTrack2Info, BSTR bstrTrack3Info, BSTR bstrRawMagcardData, LONG * bWasDataHandled)
{
if (bWasDataHandled == NULL)
return E_POINTER;
return E_NOTIMPL;
}
Is that where I implement my code? I put some test code in there to write out to a txt file just to test it. I then used:
HRESULT hr = CoCreateInstance(CLSID_AlohaMag, NULL, CLSCTX_INPROC_SERVER,
IID_IAlohaMag, (void **) &g_pIInterceptMagcard);
where g_pIInterceptMagcard is a pointer to my interface class created with the wizard above.
When I try to register I get the following HRESULT: 0x80040112
That is "class not licensed for use."
Does that mean my program didn't make the necessary registry entries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能意味着您必须先安装许可证,然后他们的自定义类工厂才能创建该类的实例。您是否尝试在磁卡刷卡许可使用的情况下在完全正常工作的 POS 系统上运行您的程序?也许您需要其他一些许可证才能执行此类操作?
如果是类没有注册的问题,结果就是“类没有注册”。听起来您已经通过向导完成了必要的步骤来实现该接口并让它生成正确的注册表项。
It probably means there is a license you have to install before their custom class factory will create an instance of the class. Did you try running your program on a fully working POS system with the magnetic card swipe licensed for use? Maybe there is some other license that you need to do this type of thing?
If it was a problem of the class not being registered, the result would be "class not registered". It sounds like you've done the necessary steps via the wizard to implement the interface and have it generate the correct registry entries.