Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. import

import

Scheduled Pinned Locked Moved C / C++ / MFC
c++comquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ROWALI
    wrote on last edited by
    #1

    I want to use COM components in my application. When to use #import and when to use CoInitialize, 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

    S _ M 3 Replies Last reply
    0
    • R ROWALI

      I want to use COM components in my application. When to use #import and when to use CoInitialize, 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

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Any thread that uses COM will have to call CoInitialize or CoInitializeEx 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

      1 Reply Last reply
      0
      • R ROWALI

        I want to use COM components in my application. When to use #import and when to use CoInitialize, 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

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • _ _AnsHUMAN_

          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

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          _AnShUmAn_ wrote:

          You can also invoke the methods of the Component using LoadLibrary() etc

          This is not the case. Steve

          1 Reply Last reply
          0
          • R ROWALI

            I want to use COM components in my application. When to use #import and when to use CoInitialize, 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

            M Offline
            M Offline
            Milton Karimbekallil
            wrote on last edited by
            #5

            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 the CoCreateInstance 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

            A 1 Reply Last reply
            0
            • M Milton Karimbekallil

              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 the CoCreateInstance 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

              A Offline
              A Offline
              Anilkumar K V
              wrote on last edited by
              #6

              Hi Milton Glad to meet u in CP Where u know? I am Anilkumar , Ex MOPL :)

              M 1 Reply Last reply
              0
              • A Anilkumar K V

                Hi Milton Glad to meet u in CP Where u know? I am Anilkumar , Ex MOPL :)

                M Offline
                M Offline
                Milton Karimbekallil
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups