2010-12-04 99 views
1

我正在使用C++ Builder XE创建COM服务器。它的ProgID总是'PROGRAMNAME.CLASSNAME'。在IDE中设置ProgID

如何更改ProgID?我想使用'COMPANYNAME.PROGRAMNAME.FUNCTIONALITY'。

Delphi答案可能就足够了。

回答

2

覆盖工厂的GetProgID方法。应遵循以下几点:

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) 
    { 
    } 
}; 

然后让COM服务器的createFactory()使用派生工厂。

干杯,

布诺

+0

感谢,将考验在接下来的一段时间,标记的答案正确的,如果它的工作原理。 – 2011-01-06 22:21:45