call a VB COM dll thru a C++ COM dll from a C program 
Author Message
 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.



Sat, 01 Dec 2001 03:00:00 GMT  
 call a VB COM dll thru a C++ COM dll from a C program
First, a bit of netiquette:  You should pick one (or
possibly two in ambiguous cases) newsgroup whose
charter best fits your question and post there.  With
your shotgun approach, you irritate a lot of the folks
that might be willing to help you.

Quote:

> 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
[big snip]
> Anybody an idea?

It is far easier to do a QueryInterface() to get
(or verify) the dual interface on your VB object,
then call its methods with the right argument
types.  Setting up an Invoke() call and taking
it down afterward is tedious and is likely to
lead to many troubles resembling yours.

Why do you insist on going thru Invoke()?

--
--
Larry Brasfield
Above opinions may be mine alone.



Sat, 01 Dec 2001 03:00:00 GMT  
 call a VB COM dll thru a C++ COM dll from a C program
I don't know much about VB, but for you problem about BSTR * and char * look at
the _bstr_t class.
Hope this will help.

Quote:

> 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;
> }

> STDMETHODIMP CSDK::SetVar(BSTR name, BSTR value, long *result)
> {
>  int temp = Funcs->SetVar((char *) name, (char *) value);
>  *result = temp;
>  return S_OK;
> }

> STDMETHODIMP CSDK::osErrorLog(BSTR message)
> {
>  osFuncs->osErrorLog((char *) message);
>  return S_OK;
> }
> ----------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.

--
Olivier THOUMIN

CAST S.A.
3, rue marcel Allgot
92190 MEUDON
FRANCE
Tel: (33) 1.46.90.21.40
Fax: (33) 1.46.90.21.41
http://www.cast.fr
http://www.castsoftware.com


Sat, 01 Dec 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. call a VB COM dll thru a C++ COM dll from a C program

2. Problem calling VB COM dll from VC++ multithreaded COM EXE client

3. VB image list handle isn't fully accessible in VC++ ActiveX thru COM call

4. problems passing ADO Recordset from VB-COM client to VC-COM-Server dll

5. call a C# class from a VB 6 COM dll

6. Calling VB COM DLL from VC++

7. VC calling a VB COM dll

8. vb client of a c++ dll-based COM server

9. com+ thru comadmin.dll

10. Calling an ATL COM Dll from C program

11. HOWTO? Calling VB DLL from C++ DLL

12. calling a method in a J++ COM DLL from C++

 

 
Powered by phpBB® Forum Software