OCX调用ATL COM的DLL的函数的方法

来源:互联网 发布:手机网络防火墙 编辑:程序博客网 时间:2024/04/30 03:38

Condition: XGraphSpeedyHold.ocx, GraphSvcApi.dll has a DBRead() function.

Purpose: XGraphSpeedyHold.ocx calls the DBRead function in IRTDB interface, in GraphSvcApi.dll, where GraphSvcApi.dll is implemented with ATL COM.

 

Realization: 

#import "../include/GraphSvcApi.tlb"

 

...

CoInitialize(NULL);

IRTDBPtr spApi = NULL;

if(FAILED(spApi.CreateInstance(__uuidof(RTDB))) == 0)

{

    AfxMessageBox("Create Instance Failed!/n");

    return -1;

}

spApi->DBRead();

CoUninitialize();

...