开发者

Setting ProgID in IDE

开发者 https://www.devze.com 2023-01-28 15:43 出处:网络
I am creating a COM server using C++ Builder XE.Its ProgID is alw开发者_StackOverflow社区ays \'PROGRAMNAME.CLASSNAME\'.

I am creating a COM server using C++ Builder XE. Its ProgID is alw开发者_StackOverflow社区ays 'PROGRAMNAME.CLASSNAME'.

How do I change the ProgID? I want to use 'COMPANYNAME.PROGRAMNAME.FUNCTIONALITY'.

A Delphi answer would probably suffice.


Override the GetProgID method of the factory. Something along the lines of the following should do:

template <typename T>
class TMyCppComObjectFactory : public TCppComObjectFactory<T>
{
protected:
  System::UnicodeString __fastcall GetProgID()
  {
    return "Company.ProgName.Functionality";
  }
public:
  __fastcall TMyCppComObjectFactory(Comobj::TComServerObject* ComServer,
          Comobj::TComClass ComClass,
          const GUID &ClassID,
          const System::String ClassName,
          const System::String Description,
          Comobj::TClassInstancing Instancing,
          Comobj::TThreadingModel ThreadingModel) :
       TCppComObjectFactory<T>(ComServer, ComClass, ClassID,
                               ClassName, Description,
                               Instancing, ThreadingModel)
  {
  }
};

Then have the createFactory() of the COM Server use the derived factory.

Cheers,

Bruneau

0

精彩评论

暂无评论...
验证码 换一张
取 消