none
Using COM DLLs with with unmanged c++ RRS feed

  • Question

  • I am still a bit new to Windows programming and sometimes find the documentation and tutorials I find confusing and sometimes contradictory but I hope I can make some sense and be corrected on any points I am mistaken about. I am using an API where the documentation included is quite poor. It is made up of a number of DLLs that they envisioned would be added as a reference to VB projects (most of the users are biologists/chemists and are not very familiar with other languages, so they recommend VB). I thought they were .NET dlls at first but they cannot be registered with regasm and a tlb cannot be generated using this but can be registered with regsvr32, so I guess that means they are COM dlls...please correct me if I am wrong.

    My understanding is that as this exposes the COM objects that I should be able to use this with .NET languages and unmanged c++. I have used it in C# but I would also like to use this in unmanged c++. I have seen tutorials like this: http://cppkid.wordpress.com/2009/01/...nmanaged-code/ That import the type library but I do not have this, it was not supplied with the API. However using OLE viewer I was able to see that they were available (embedded in the dll?). Can I simply import the dll using the #import directive?  I was wondering if anyone knows how I can go from this to actually using the dll in c++.

    Cheers and thanks for any help.

    Tuesday, February 7, 2012 7:35 PM

Answers

  • Hello MrProsser,

    1. >> ...but can be registered with regsvr32, so I guess that means they are COM dlls...please correct me if I am wrong...

    Yes, if it can be registered using regsvr32, it is definitely a (unmanaged) COM DLL.

    2. >> However using OLE viewer I was able to see that they were available (embedded in the dll?).

    Yes, the TLB is embedded as a resource of a COM DLL.

    3. >> Can I simply import the dll using the #import directive?

    Yes, you can #import the DLL.

    4. The end result of such an #import statement is that the Visual C++ compiler will produce the C++-language-specific constructs (classes, structs, macros and typedefs, etc) that will represent the COM classes and interfaces defined in the .TLB.

    5. These C++-specific representations of the COM classes and interfaces are what allows your application code to instantiate the COM classes and call the properties and methods of the interfaces of the COM classes.

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    • Marked as answer by Paul Zhou Thursday, February 16, 2012 8:13 AM
    Wednesday, February 8, 2012 12:33 AM