Calling COM DLL from .c files 
Author Message
 Calling COM DLL from .c files

I have a third party COM DLL written in VB (just application extension).
I need to call it from C program (done in VC++ environment). I tried
doing this with the common # import, as follows:
#import "E:\Program Files\SampleCOM.dll" no_namespace
However, this does not work, I get the following error:

error C2773: #import only available in C++ compiler
(which is logical).

However, I have no idea how to call this from C?!
I have been searching the MSDN etc. but for the life of me could not
find SIMPLE, and straightforward explanation.
I would REALLY appreciate any help.
Thanks a lot.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 16 Mar 2003 03:00:00 GMT  
 Calling COM DLL from .c files

Do you know that you can mix C and CPP files in a project?
If you really want to use C, have a look at:
CoInitialize(Ex)
CoCreateInstance(Ex)
GetIDsOfNames (if you don't have any include file)
Invoke
and you have to call some of them like: pDispatch->lpVtbl->Invoke(...) where
pDispatch is a pointer to your object.

Cheers,
Guillaume.

Quote:

> I have a third party COM DLL written in VB (just application extension).
> I need to call it from C program (done in VC++ environment). I tried
> doing this with the common "# import", as follows:
> #import "E:\Program Files\SampleCOM.dll" no_namespace
> However, this does not work, I get the following error:

> error C2773: #import only available in C++ compiler
> (which is logical).

> However, I have no idea how to call this from C?!
> I have been searching the MSDN etc. but for the life of me could not
> find SIMPLE, and straightforward explanation.
> I would REALLY appreciate any help.
> Thanks a lot.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 16 Mar 2003 03:00:00 GMT  
 Calling COM DLL from .c files
You may also want to build a dummy COM object and take a look at the C
helper macros generated by MIDL.  Look for COBJMACROS in the generated .h.


Quote:

> Do you know that you can mix C and CPP files in a project?
> If you really want to use C, have a look at:
> CoInitialize(Ex)
> CoCreateInstance(Ex)
> GetIDsOfNames (if you don't have any include file)
> Invoke
> and you have to call some of them like: pDispatch->lpVtbl->Invoke(...)
where
> pDispatch is a pointer to your object.

> Cheers,
> Guillaume.




Quote:
> > I have a third party COM DLL written in VB (just application extension).
> > I need to call it from C program (done in VC++ environment). I tried
> > doing this with the common "# import", as follows:
> > #import "E:\Program Files\SampleCOM.dll" no_namespace
> > However, this does not work, I get the following error:

> > error C2773: #import only available in C++ compiler
> > (which is logical).

> > However, I have no idea how to call this from C?!
> > I have been searching the MSDN etc. but for the life of me could not
> > find SIMPLE, and straightforward explanation.
> > I would REALLY appreciate any help.
> > Thanks a lot.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.



Sun, 16 Mar 2003 03:00:00 GMT  
 Calling COM DLL from .c files

We're mixing C and CPP files to call some VB COM DLLs from an old C
application.  So far works great.  We put the #import in an HPP file and
write routines in a CPP file to access the COM object.  The CPP routines are
defined as   extern "C"  so the routine names aren't mangled so the C
routines can refer to 'em.   The tradeoff is we have to write one of these
CPP "wrapper" routines for each access to the COM that the C routines need
to make.

- Mark


Quote:
> Do you know that you can mix C and CPP files in a project?
> If you really want to use C, have a look at:
> CoInitialize(Ex)
> CoCreateInstance(Ex)
> GetIDsOfNames (if you don't have any include file)
> Invoke
> and you have to call some of them like: pDispatch->lpVtbl->Invoke(...)
where
> pDispatch is a pointer to your object.

> Cheers,
> Guillaume.




Quote:
> > I have a third party COM DLL written in VB (just application extension).
> > I need to call it from C program (done in VC++ environment). I tried
> > doing this with the common "# import", as follows:
> > #import "E:\Program Files\SampleCOM.dll" no_namespace
> > However, this does not work, I get the following error:

> > error C2773: #import only available in C++ compiler
> > (which is logical).

> > However, I have no idea how to call this from C?!
> > I have been searching the MSDN etc. but for the life of me could not
> > find SIMPLE, and straightforward explanation.
> > I would REALLY appreciate any help.
> > Thanks a lot.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.



Fri, 11 Apr 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calling COM DLL from .c files

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

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

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

5. problem getting header file for the COM dll that uses msado15.dll

6. HELP: Call other DLLs from a COM

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

8. C DLL making calls to a COM object

9. Calling a COM object from a C dll

10. Calling "unmanaged" com dll from c#

11. HELP: Call other DLLs from a COM

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

 

 
Powered by phpBB® Forum Software