Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
dear all

i have a dll that contain a COM METHOD functions and i want to use these functions in a c++ console application i searched alot for a tutorial or something to help me but nothing
please can you help me in this

i only have the DLL file no other files(source codes,manifest,............)
i use visual studio 2010

thanks in advance
Posted
Updated 26-May-11 13:49pm
v3

The fact that you're writing a console application should be irrelevent. You want to instantiate a COM object and invoke a method.

You can do it the hard way,[^] or let the IDE help you out.[^]

You don't say if you're using managed or unmanaged C++ which will make a big difference, so I can't really point you to a tutorial, but here's a start.[^]
 
Share this answer
 
v2
Comments
Member 7788393 26-May-11 19:32pm    
it is unmanaged
Member 7788393 28-May-11 18:44pm    
where is the help :D
if it's got a type library embedded in it, it's fairly easy

// get ATL's client templates
#include <atlcomcli.h>
// import the typelibrary direct from the dll
#import "<name of your com dll here>" raw_interfaces_only no_namespace


That will create a .tlh file in your output directory - have a look at that for the object and interface declaration

then to use that com object
// declare com ptr
CComPtr<IwhateverTheInterfaceIs> comInterfacePtr;
// cocreate an instance
comInterfacePtr.CoCreateInstance(__uuidof(theCoClassFromTLHfile))
// then use methods
comInterfacePtr->Method()
 
Share this answer
 
Comments
Member 7788393 26-May-11 20:43pm    
thank you barneyman i will try this as soon as possible as i have exams and alot of study and work
Member 7788393 28-May-11 18:34pm    
no it is not work no type library embedded in it
barneyman 28-May-11 23:24pm    
without an embedded type library, or a standalone tlb file, you're rather snookered ...

makerj 4-Apr-20 23:17pm    
#include <atlcomcli.h>

By adding this before first #import directive, intellisense/compile error has been fixed! Thank you @barneyman you saved my day!

And don't foget to call CoInitialize[Ex] before invoking CoCreateInstance method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900