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. ADO in a DLL

ADO in a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
comhostingquestion
5 Posts 2 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.
  • S Offline
    S Offline
    staticv
    wrote on last edited by
    #1

    Hey, I wanted to know that whether it is safe to use ADO in a DLL? The reason I'm asking this is that, to use ADO we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?

    Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

    L 1 Reply Last reply
    0
    • S staticv

      Hey, I wanted to know that whether it is safe to use ADO in a DLL? The reason I'm asking this is that, to use ADO we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?

      Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Ahmed Manzoor wrote:

      we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?

      Yes. You do it and the matching uninitialize in DLLMain for every Process and Thread attach/detach message. From the documentation: Because there is no way to control the order in which in-process servers are loaded or unloaded, do not call CoInitialize, CoInitializeEx, or CoUninitialize from the DllMain function. link[^]

      S 1 Reply Last reply
      0
      • L led mike

        Ahmed Manzoor wrote:

        we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?

        Yes. You do it and the matching uninitialize in DLLMain for every Process and Thread attach/detach message. From the documentation: Because there is no way to control the order in which in-process servers are loaded or unloaded, do not call CoInitialize, CoInitializeEx, or CoUninitialize from the DllMain function. link[^]

        S Offline
        S Offline
        staticv
        wrote on last edited by
        #3

        What do you mean? Is it safe? Will there be any malfunction?

        Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

        L 1 Reply Last reply
        0
        • S staticv

          What do you mean? Is it safe? Will there be any malfunction?

          Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Ahmed Manzoor wrote:

          Will there be any malfunction?

          That depends on you, your analysis of your scenario and developing a correct solution. Make sure you read the documentation I provided a link to. The best scenario is the host process has already handled COM initialization. If that isn't happening then you have a less than perfect scenario. Make sure you understand the ramifications and develop the proper error handling code for the potential scenarios that could occur based on your hosting scenario. My fault, I should have mentioned that your scenario can also call for dealing with the initialization in other exports of your DLL rather than DLLMain. The problem with that is you need to account for the messages you get passed in DLLMain so that you know which event is happening. It's really up to you to figure all this out based on your project details.

          S 1 Reply Last reply
          0
          • L led mike

            Ahmed Manzoor wrote:

            Will there be any malfunction?

            That depends on you, your analysis of your scenario and developing a correct solution. Make sure you read the documentation I provided a link to. The best scenario is the host process has already handled COM initialization. If that isn't happening then you have a less than perfect scenario. Make sure you understand the ramifications and develop the proper error handling code for the potential scenarios that could occur based on your hosting scenario. My fault, I should have mentioned that your scenario can also call for dealing with the initialization in other exports of your DLL rather than DLLMain. The problem with that is you need to account for the messages you get passed in DLLMain so that you know which event is happening. It's really up to you to figure all this out based on your project details.

            S Offline
            S Offline
            staticv
            wrote on last edited by
            #5

            Well now, I guess I would have to use another solution. Thanks anyways

            Top Web Hosting Providers[^] Do, or do not. There is no 'try'.

            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