
call a VB COM dll thru a C++ COM dll from a C program
Hi all,
I am trying to call a VB COM dll thru a C++ COM dll from a C program. I got
passed:
CLSIDFromProgID
CoInitialize
CoCreateInstance
GetIDsOfNames
and I am stuck at:
Invoke
The c program calls the C++ COM dll (1st problem: converting von BSTR * to
char * and vice versa) with a parameter what other dll to call. For testing
I created a VB COM dll with a function "LoadCOM" that has always have to be
available on order to call it from the C++ dll. This is basically the main
for the modul. This itself then can call functions in the C++ dll that are
publizised.
I can resolve the function name but I always get DISP_E_EXCEPTION error
where I don't know what to do with it and second fix that problem.
Anybody an idea?
The source of the C++ dll:
----------8<----------8<----------8<----------8<----------8<-------
...
DISPID dispid;
BSTR szMember = L"LoadCOM";
hr = pIDispatch->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT,
&dispid);
if (FAILED(hr)) { // Error }
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
EXCEPINFO ExcepInfo;
hr = pIDispatch->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD,bh
&dispparamsNoArgs, NULL, &ExcepInfo, NULL);
if (FAILED(hr)) {
switch (hr) {
...
STDMETHODIMP CSDK::GetConf(BSTR parameter, BSTR *value)
{
value = (unsigned short **) Funcs->GetConf(handle, (char *) parameter);
return S_OK;
Quote:
}
STDMETHODIMP CSDK::SetVar(BSTR name, BSTR value, long *result)
{
int temp = Funcs->SetVar((char *) name, (char *) value);
*result = temp;
return S_OK;
Quote:
}
STDMETHODIMP CSDK::osErrorLog(BSTR message)
{
osFuncs->osErrorLog((char *) message);
return S_OK;
Quote:
}
----------8<----------8<----------8<----------8<----------8<-------
The source of the VB dll:
the SDK. fcts are publizised by the C++ dll
----------8<----------8<----------8<----------8<----------8<-------
Public Function LoadCOM()
Dim oshome As String
Dim ret As Integer
ret = MsgBox("I was called", vbOKOnly)
home = SDK.GetConf("home")
SDK.ErrorLog ("VB was here")
ret = SDK.SetVar("comerror", "VB OK")
End Function
----------8<----------8<----------8<----------8<----------8<-------
Anybody an idea?
thanx,
Ingo.