COM的调用

来源:互联网 发布:全球经济数据 市盈率 编辑:程序博客网 时间:2024/06/09 16:47

C#中:
1:添加引用
2:using comtest;命名空间
3:对象声明于调用
   comtest.testclass testclass1=new comtest.testclassClass();
   testclass1.read_jpg();

VC中:
添加.h和.c文件后
  if(FAILED(CoInitialize(NULL)))
 {
  AfxMessageBox("Unable to initialize COM.",MB_OK);
  return;
 }

 Itestclass* read=NULL;
 
 HRESULT hr=CoCreateInstance(CLSID_testclass,NULL,
  CLSCTX_ALL,IID_Itestclass,(void* *)&read);
 
 if(SUCCEEDED(hr))
 {
  read->read_jpg();
 }
 read->Release();   

原创粉丝点击