import
-
I want to use COM components in my application. When to use
#import
and when to useCoInitialize, CoCreateInstance(..)
Are both reaching to same destination? Or #import has to be used with ATL executable and CoInitialize, CoCreateInstance has to be used with InProcess Dlls Please confirm? Row -
I want to use COM components in my application. When to use
#import
and when to useCoInitialize, CoCreateInstance(..)
Are both reaching to same destination? Or #import has to be used with ATL executable and CoInitialize, CoCreateInstance has to be used with InProcess Dlls Please confirm? RowAny thread that uses COM will have to call
CoInitialize
orCoInitializeEx
to initialize COM on that thread and tell the COM runtime which apartment the thread belongs to.CoCreateInstance
is the most common API for object creation.#import
is used to get the compiler to generate C++ wrapper classes for COM interfaces from type libraries. Steve -
I want to use COM components in my application. When to use
#import
and when to useCoInitialize, CoCreateInstance(..)
Are both reaching to same destination? Or #import has to be used with ATL executable and CoInitialize, CoCreateInstance has to be used with InProcess Dlls Please confirm? RowCoInitialize() Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA). Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions. (This is from the docs) Now you can instantiate your component using CoCreateInstance() You can also invoke the methods of the Component using LoadLibrary() etc Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_ -- modified at 8:33 Tuesday 20th June, 2006
-
CoInitialize() Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA). Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions. (This is from the docs) Now you can instantiate your component using CoCreateInstance() You can also invoke the methods of the Component using LoadLibrary() etc Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_ -- modified at 8:33 Tuesday 20th June, 2006
_AnShUmAn_ wrote:
You can also invoke the methods of the Component using LoadLibrary() etc
This is not the case. Steve
-
I want to use COM components in my application. When to use
#import
and when to useCoInitialize, CoCreateInstance(..)
Are both reaching to same destination? Or #import has to be used with ATL executable and CoInitialize, CoCreateInstance has to be used with InProcess Dlls Please confirm? RowAs everybody mentioned you have to call
CoInitialize
to load/map the COM subsystem into your process memory. This is vital. Then to use/invoke calls on the Component classes: Either you can use#import
approach or theCoCreateInstance
approach. As a beginner I would recommend you to go for#import
as this is comparatively easy. It wraps most of the COM complexities under Smart pointers. Also this is not the place for posting COM related questions. Going forward please do it in the COM section cheers...milton Kb -
As everybody mentioned you have to call
CoInitialize
to load/map the COM subsystem into your process memory. This is vital. Then to use/invoke calls on the Component classes: Either you can use#import
approach or theCoCreateInstance
approach. As a beginner I would recommend you to go for#import
as this is comparatively easy. It wraps most of the COM complexities under Smart pointers. Also this is not the place for posting COM related questions. Going forward please do it in the COM section cheers...milton KbHi Milton Glad to meet u in CP Where u know? I am Anilkumar , Ex MOPL :)
-
Hi Milton Glad to meet u in CP Where u know? I am Anilkumar , Ex MOPL :)
Hey glad 2 hear from u. I was in seattle,WA. Juz back at Blr last friday. Come 2 milton.kbaby@cognizant.com / miltonkb@msn.com rgds...milton kb.