How to determine the implementation of a COM class?

I am new to COM, and I browsed the web to find out how to create a COM class in C ++ (for using C #). I saw this in the .idl file, I should add something like this:

[
object,
uuid(a93164ee-e6d4-44be-aa27-f00ce6972719),
helpstring("interface ITopologyQuery")
]

interface ITopologyQuery : IUnknown
{
  HRESULT LoadFile(BSTR completeFileName);

  HRESULT SetParameters(int above, int percentage);
}

[
  uuid(a958f2af-8b55-43c4-9fc3-c39d83fc1376)
]
library TopologyQueryLib
{
  [
    uuid(cc814992-31ec-4a1f-a41e-111ade27bdfe),
    helpstring("TopologyQuery class")
  ]
  coclass CTopologyQuery
  {
    [default] interface ITopologyQuery;
  };
}

Now my question is: where do you define the CTopologyQuery class? If I define it as a regular C ++ class in another file, will the compiler correctly associate my class with an interface? The code of the C ++ class looks like this (it is implemented in the .cpp file):

class CTopologyQuery : public ITopologyQuery
{
  public:

    __stdcall CTopologyQuery();

    //IUnknown interface 
    HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj);
    ULONG   __stdcall AddRef();
    ULONG   __stdcall Release();

    //ITopologyQuery interface
    HRESULT __stdcall LoadTopologyFile(BSTR completeFileName);
    HRESULT __stdcall SetParameters(int above, int percentage);

  private:
};

While it compiles, if I put the library section in the .idl file, or if I do not. I lost a little, how good, what can be done here? I understand that the definition of coclass should give a default implementation for the interface, but for me it looks like an empty class without methods ...

+5
1

IDL ( ) , ++.

, DLL COM. Microsoft COM/OLE Viewer .

++- IDispatch , , ++ ( ), ++.

IDL, , COM C # . , Windows, COM CoCreateInstance . , , , COM-.

hth.,

+5

All Articles