Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to write a sample COM.
VC++ IDE provides a wizard to create a Simple COM object.
However, it always creates the COM object with IDispatch support.

For some reasons, I need to create a Simple COM object implementing the following IDL with the following requirements:
-- Must be COM exe
-- Must not be derived from IDispatch but IUnknown only
-- Must be a singleton

C++
// typelib filename: Sample.exe
[
  uuid(94EE69BF-4387-4078-B33F-1E9B471D128E),
  version(1.0),
  helpstring("Sample 1.0 Type Library"),
)
]

// library Sample
{
    importlib("stdole2.tlb");
    // Forward declare all types defined in this typelib
    interface ISample;
    [
      uuid(7CEBF979-C4EB-48eb-BE06-FBA1B4929FE7),
      version(1.0)
    ]
    coclass CSample
    {
        [default] interface ISample;
    };
    [
      odl,
      uuid(E3B868FC-7A58-4f28-B895-922D2BE7797F),
      oleautomation
    ]
    interface ISample : IUnknown
    {
        HRESULT _stdcall CreateTester([out, retval] IUnknown** ppTester);
        HRESULT _stdcall Initialize();
        HRESULT _stdcall Uninitialize();
        HRESULT _stdcall get_Name([out, retval] BSTR* Name);
        HRESULT _stdcall GetSettings([out, retval] IUnknown** ppSettings);
        HRESULT _stdcall GetList([out, retval] VARIANT* VarList);
        HRESULT _stdcall SetList([in] VARIANT VarList);
    };
};


I created an ATL COM project this using VC++ wizard and tried to stripping off IDispatch out of it.
However, it turned out to be too difficult job to give up.

Can someone write a COM project satisfying the above requirements please?

Thank you.

--
HaeRim Lee
Posted
Updated 2-Jul-10 22:19pm
v2

1 solution

Have a look at this article: Beginner's Tutorial: COM/ATL Simple Project[^]

You could use it as a base for your own project.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900