首页 / C++ / C++ com 组件的使用
C++ com 组件的使用
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了C++ com 组件的使用,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2087字,纯文字阅读大概需要3分钟。
内容图文
// CommonTest.cpp : This file contains the ‘main‘ function. Program execution begins and ends there.
//
#include <iostream>
#include <atlbase.h>
#include "mbnapi.h"
int main()
{
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr))
{
return -1;
}
CComPtr<IMbnInterfaceManager> mbnInterfaceMgr = NULL;
hr = CoCreateInstance(CLSID_MbnInterfaceManager,NULL,CLSCTX_ALL,IID_IMbnInterfaceManager,(void**)&mbnInterfaceMgr);
if (FAILED(hr))
{
return -1;
}
SAFEARRAY* psa = NULL;
hr = mbnInterfaceMgr->GetInterfaces(&psa);
if (FAILED(hr))
{
CoUninitialize();
return -1;
}
LONG lLower;
hr = SafeArrayGetLBound(psa, 1, &lLower);
if (FAILED(hr))
{
CoUninitialize();
return -1;
}
LONG lUpper;
hr = SafeArrayGetUBound(psa, 1, &lUpper);
if (FAILED(hr))
{
CoUninitialize();
return -1;
}
CComPtr<IMbnInterface> pInf = NULL;
for (LONG l = lLower; l <= lUpper; l++)
{
hr = SafeArrayGetElement(psa, &l, (void*)(&pInf));
if (SUCCEEDED(hr))
{
CComPtr<IMbnSubscriberInformation> subscriberInf = NULL;
hr = pInf->GetSubscriberInformation(&subscriberInf);
if (SUCCEEDED(hr)) {
WCHAR tszID[256] = { L‘\0‘ };
hr = subscriberInf->get_SubscriberID((BSTR*)&tszID);
if (SUCCEEDED(hr)) {
std::wcout << L"SubscriberID: " << tszID <<std::endl;
}
}
}
}
SafeArrayDestroy(psa);
CoUninitialize();
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
原文:https://www.cnblogs.com/bruce1992/p/14943024.html
内容总结
以上是互联网集市为您收集整理的C++ com 组件的使用全部内容,希望文章能够帮你解决C++ com 组件的使用所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。