2

I'm new to COM so this maybe a stupid question, but I'll ask it anyway. :)

As far as I understand, in order to make a DLL COM we need to define its interface in a .idl file, compile it with the MIDL compiler and then simply implement the classes that use the defined interfaces. Then we need to expose the DllRegisterServer, DllUnregisterServer and DllGetClassObject. and it should be enough, right?

But I did all this and when I try to check it in a client C++ program, my visual studio says (on the #import statement) that it can't find the tlh file...

This is how my .idl looks like:

import "someIdl.idl";

[
    uuid(some-guid-Num1),
    version(1.0),
    helpstring("The library's description")
]
library LibName
{
    importlib("stdole2.tlb");
    [
        uuid(some-guid-Num2),
        helpstring("Some Description")
    ]
    coclass ClassName
    {       
        interface Interface_defined_in_someIdl;
    }
};

Am I missing something in the .idl? Did I get the COM making process wrong?

3
  • 1
    My COM is a little rusty but did you remember to use regsvr32 to register the DLL?
    – john
    Oct 31, 2012 at 12:55
  • I do. I register both GUIDs (the library's and class's) to Current User\Classes\CLSID. Is the library's GUID supposed to be registered to another location?
    – Idov
    Oct 31, 2012 at 15:10
  • But I think it's not it. I have another COM DLL that I downloaded, unregistered it and didn't get the error...
    – Idov
    Oct 31, 2012 at 15:23

1 Answer 1

1

The problem was that I didn't embed the TLB file into the DLL as resource.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.