访问 uccapi.dll COM 接口 C++ 时出现问题
我正在从事一个涉及 Microsoft 统一通信客户端 API 的项目; uccapi.dll。我还使用 Codegear C++Builder 2010,而不是 Visual Studio。使用 regsvr32 注册 dll 并将其作为类型库导入 C++Builder 2010 后,生成了 uccapi_tlb- 和 uccapi_ocx- 文件。将这些导入到我的新项目中时,我尝试遵循 msdn 指南,用于创建能够登录 Office Communication 服务器的 Office Communicator 客户端。
在这方面,我有两个问题:
- 访问通过 ocx 提供的 com 接口的正确方法是什么?
到目前为止,我已经找到了几种创建接入点的方法,例如。
TCOMIUccPlatform plat;
plat = CoUccPlatform::Create();
和
IUccPlatformPtr im;
im = CreateComObject(CLSID_UccPlatform);
和
IUccPlatform* pIUccPlatform;
hr = CoCreateInstance(CLSID_UccPlatform,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IUccPlatform),
(void**)&pIUccPlatform);
前
IUccPlatformPtr pIPlat;
pIPlat.CreateInstance(__uuidof(IUccPlatform));
三个似乎效果很好。后者会给我一个 Assertion failed: intf!=0 错误,并带有 0×40000015 异常。使用前三个中的任何一个,我都可以访问方法并初始化平台接口。
然而,当尝试使用任何相同的策略来访问任何其他接口时,例如 IUccContext、IUccUriManager 或 IUccUri,所有这些接口都定义了 clsid在 _tlb.h 文件中,我要么在前两种情况下收到“类未注册”错误,要么在第三种情况下收到 hresult 失败。这引出了我的下一个问题。
- 使用 ole-viewer,所有接口都按其应有的方式注册。为什么注册 dll 时不注册 dll 中所有可共同创建的类?他们不采取类似行动的原因可能是什么?
来自 UCCAPILib_tlb.h 的 Edit1:
//
// COCLASS DEFAULT INTERFACE CREATOR
// CoClass : UccPlatform
// Interface: TCOMIUccPlatform
//
typedef TCoClassCreatorT<TCOMIUccPlatform, IUccPlatform, &CLSID_UccPlatform, &IID_IUccPlatform> CoUccPlatform;
//
// COCLASS DEFAULT INTERFACE CREATOR
// CoClass : UccUriManager
// Interface: TCOMIUccUriManager
//
typedef TCoClassCreatorT<TCOMIUccUriManager, IUccUriManager, &CLSID_UccUriManager, &IID_IUccUriManager> CoUccUriManager;
I'm working on a project involving the Microsoft Unified Communications Client API; uccapi.dll. I'm also using Codegear C++Builder 2010, not Visual Studio. After registering the dll with regsvr32 and importing it as type library into C++Builder 2010, uccapi_tlb- and uccapi_ocx-files were generated. When having imported these into my new project I'm trying to follow the msdn guideline for creating a Office Communicator Client able of signing into the Office Communication server.
In this regard I have two questions:
- What is the correct way of accessing the com-interfaces made available through the ocx?
I've so far found several ways of creating access points, such as.
TCOMIUccPlatform plat;
plat = CoUccPlatform::Create();
and
IUccPlatformPtr im;
im = CreateComObject(CLSID_UccPlatform);
and
IUccPlatform* pIUccPlatform;
hr = CoCreateInstance(CLSID_UccPlatform,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IUccPlatform),
(void**)&pIUccPlatform);
and
IUccPlatformPtr pIPlat;
pIPlat.CreateInstance(__uuidof(IUccPlatform));
The three first seem to work well. The latter will give me an Assertion failed: intf!=0 error with 0×40000015 exception. Using any of the three top ones I can access methods and initialize the platform interface.
However when trying any of the same tactics to access any other interface, such as IUccContext, IUccUriManager or IUccUri, all of which have a clsid defined in the _tlb.h file, I either get a "class not registered" error in the first two cases, or a hresult failure in the third case. Which brings me to my next question.
- Using ole-viewer all interfaces are registered as they should. Why wouldn't all co-creatable classes in the dll be registered when registering the dll? And what could be the reasons why don't they act similarly?
Edit1 from UCCAPILib_tlb.h:
//
// COCLASS DEFAULT INTERFACE CREATOR
// CoClass : UccPlatform
// Interface: TCOMIUccPlatform
//
typedef TCoClassCreatorT<TCOMIUccPlatform, IUccPlatform, &CLSID_UccPlatform, &IID_IUccPlatform> CoUccPlatform;
//
// COCLASS DEFAULT INTERFACE CREATOR
// CoClass : UccUriManager
// Interface: TCOMIUccUriManager
//
typedef TCoClassCreatorT<TCOMIUccUriManager, IUccUriManager, &CLSID_UccUriManager, &IID_IUccUriManager> CoUccUriManager;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Embarcadero 论坛 已详细讨论此问题。
This issue is already being discussed in detail in the Embarcadero forums.