佚名通过本文主要向大家介绍了vc++组件,vc++组件下载,vc++6.0官方下载,vc++,vc++6.0中文版下载等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: VC++引用COM组件
描述:
解决方案1:
描述:
我是初学VC++的,在VB下做了一个COM组件(是dll的),要在VC++中引用,调用里面的函数,怎么做?
解决方案1:
//智能指针,
#include <atlbase.h>
#import "MyDesLib.tlb" named_guids no_namespace
int main(int argc, char* argv[])
{
HRESULT hr;
hr = CoInitialize(0);
if( SUCCEEDED(hr) )
{
CComPtr<ICustomDes> pCustomDes;
hr = pCustomDes.CoCreateInstance(CLSID_CustomDes);
if( SUCCEEDED(hr) )
{
pCustomDes->Set_TestValue(100);
printf("ok,%d",pCustomDes->Get_TestValue());
}
}
CoUninitialize();
printf("Hello World!\n");
return 0;
}