I am updating an MFC application that contains a custom ActiveX control. As a part of the update I have had cause to add new methods to the ActiveX control and so it now has a different interface to the old version. The changes had no impact on the original methods and so older clients can still use the new component.
I've got everything working but I know that what I have done is smelly! What is the correct way of updating a COM/ActiveX interface.
This component was built using MFC and Googling does not provide much help beyond basic 'Create an ActiveX control with MFC' type tutorials. I can find loads of stuff about ATL but I don't want to port the component over.
I have had various suggestions from colleagues such as change the guids and inherit the interface but nothing definitive.
So generally what is considered best practise for updating COM interfaces?
And if you happen to know how this is specifically done in an MFC environment that would be really helpful too.
I've tried creating a second interface (see below) as suggested by MSalters but I'm not sure that I've gone about it correctly. I've created a new interface and a new coclass in the odl file. This results in two separate wrapper classes being generated by MFC in the client Application, one derived from CWnd for coclass Test and one derived from COleDispatchDriver for coclass Test2 - I would have expected two similar wrapper classes....
library TestLib
{
importlib(STDOLE_TLB);
// This is the original interface.......
[ uuid(D2F8E5A8-8A95-463C-814F-B3CF84286223)]
dispinterface _DTest
{
properties:
methods:
[id(1)] short TestMethod();
};
// Class information for CTestCtrl
[ uuid(1DBD2333-2073-4FB6-89AC-E4B200ADED48), control ]
coclass Test
{
[default] dispinterface _DTest;
};
// This is the new interface.
[ uuid(D2F8E5A8-8A95-463C-814F-B3CF84286224)]
dispinterface _DTest2
{
properties:
methods:
[id(1)] short TestMethod();
[id(2)] short TestMethod2();
};
// Class information for CTestCtrl2
[ uuid(1DBD2333-2073-4FB6-89AC-E4B200ADED49), control ]
coclass Test2
{
[default] dispinterface _DTest2;
};
};