An object that has a pointer to the moniker object's IMoniker interface can locate, activate, and get access to the identified object without having any other specific information on where the object is actually located in a distributed system. Implement IMoniker only if you are writing a new moniker class. This is necessary only if you need to identify objects that cannot be identified using one of the COM-supplied moniker classes described below.

解决方案 »

  1.   

    class WhoAmI {
        A_func*(...); 
        B_func*(...); 
        enum { IamA, IamB } m_Type; 
        WhoAmI(init_type) : m_Type(init_type) {}
    }; 
    #define ClassA WhoAmI(IamA)
    #define ClassB WhoAmI(IamB)
    #define Moniker(x) Class##x *有时候我们需要很多种类,但是它们都有类似之处,
      -   通过FSP(暴力工程)为每个类定义一个CLSID,当然从数学角度看这是个不会收敛的过程;
      -   声明一个通用类,通过初始化完成各种子类的合并。但这样做使各子类看起来不够独立,而且在应用中也有很多不便;
      -   为上述通用类建立子类包装,连接通用类的名字和用于初始化的参数,比如CFileDialog(FALSE) ==> CFileDialog_FALSE, 这个名字被称作“DisplayName”,以后建立该类时通过“CreateByDisplayName("CFileDialog_FALSE")”来完成。