Straight C -- Do a LoadLibrary() followed by GetProcAddress() calls for each of the exported functions you want to use. This would be "late bound"
Or...
Link the DLL statically into your project. This would be "early bound".
Hi
chiph, it is a COM program.
Ryank,
------------------------------------
GUID guid;
IDispatch* pDisp;
HRESULT hr;
hr=CLSIDFromProgID(L"x.x",&guid);
hr=CoCreateInstance(guid,NULL,CLSCTX_INPROC_SERVER,
DDI_IDispatch,&pDisp);
//do something
pDisp->Release();
////the interface pDisp is an analog of you object in VB.
-----------------------------------
Also a better way is to obtain at the first the interface IUnknown:
GUID guid;
IDispatch* pDisp;
IUnknown* pUnk;
HRESULT hr;
hr=CLSIDFromProgID(L"x.x",&guid);
hr=CoCreateInstance(guid,NULL,CLSCTX_INPROC_SERVER,
DDI_IUnknown,&pUnk);
hr=pUnk->QueryInterface(IID_IDispatch,&pDisp);
//do something
pDisp->Release();
pUnk->Release();
With interface IUnknown you can query all interfaces what the object expose.
----------------------------------
you should check on errors the hresult (hr) after each function executed.
if(FAILED(hr))
{
....
}
or
if(SUCCEDED(hr))
{
}
-------------
To begin working with COM you must call
hresult=OleInitialize(NULL);
or CoInitialize(...).
after end of COM programming call
OleUninitialize().
Using the ATL smart pointers and the '#import' statement to generate the template typedefs is WAY easier and safer than interfacing directly with COM API's.
"But, that's just my opinion... I could be wrong".
-pete
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.