当前位置: 首页 > 知识库问答 >
问题:

请问有没c++大佬帮忙看一下这个.idl,我想这个com的 CLSD 和IID是什么?

毕浩渺
2023-08-02

idl文件,内容比较多,我删减了一些东西,不知道大佬可以从这里面看出哪个是 CLSD 和IID不。
有偿!!!有偿!!!有偿!!!很急

#define DISPID_NEWENUM -4import "oaidl.idl";import "ocidl.idl";//==============================================================================// Forward declarations.interface OPCBrowser; interface OPCGroups;interface OPCGroup;interface OPCItems;interface OPCItem;//==============================================================================// IOPCServerEvent[    object,    dual,    uuid(28E68F90-8D75-11d1-8DC3-3C302A000000),    helpstring("OPCServer Events"),    pointer_default(unique),    oleautomation]interface IOPCServerEvent : IDispatch{    HRESULT ServerShutDown(       [in,string] BSTR Reason    );};//==============================================================================// IOPCGroupsEvent[    object,    dual,    uuid(28E68F9C-8D75-11d1-8DC3-3C302A000000),    helpstring("OPCGroups Event"),    pointer_default(unique),    oleautomation]interface IOPCGroupsEvent : IDispatch{    [helpstring("Event to update item data from any group")]    HRESULT GlobalDataChange(        [in] LONG                TransactionID,        [in] LONG                GroupHandle,        [in] LONG                NumItems,        [in] SAFEARRAY(LONG)*    ClientHandles,        [in] SAFEARRAY(VARIANT)* ItemValues,        [in] SAFEARRAY(LONG)*    Qualities,        [in] SAFEARRAY(DATE)*    TimeStamps    );};//==============================================================================// IOPCGroupsEvent[    object,    dual,    uuid(28E68F90-8D75-11d1-8DC3-3C302A000001),    helpstring("OPCGroup Events"),    pointer_default(unique),    oleautomation]interface IOPCGroupEvent : IDispatch{    [helpstring("Event to notify when active data has changed")]    HRESULT DataChange(        [in] LONG                TransactionID,        [in] LONG                NumItems,        [in] SAFEARRAY(LONG)*    ClientHandles,        [in] SAFEARRAY(VARIANT)* ItemValues,        [in] SAFEARRAY(LONG)*    Qualities,        [in] SAFEARRAY(DATE)*    TimeStamps    );    [helpstring("Event to update item data when a read request was completed")]    HRESULT AsyncReadComplete(        [in] LONG                TransactionID,        [in] LONG                NumItems,        [in] SAFEARRAY(LONG)*    ClientHandles,        [in] SAFEARRAY(VARIANT)* ItemValues,        [in] SAFEARRAY(LONG)*    Qualities,        [in] SAFEARRAY(DATE)*    TimeStamps,        [in] SAFEARRAY(LONG)*    Errors    );    [helpstring("Event to notify when a write request was completed")]    HRESULT AsyncWriteComplete(        [in] LONG             TransactionID,        [in] LONG             NumItems,        [in] SAFEARRAY(LONG)* ClientHandles,        [in] SAFEARRAY(LONG)* Errors    );    [helpstring("Event to notify when a cancel transaction request was completed")]    HRESULT AsyncCancelComplete(        [in] LONG TransactionID    );};//==============================================================================// OPCAutomation[   uuid(28E68F91-8D75-11d1-8DC3-3C302A000000),   version(1.0),   helpstring("OPC DA Automation Wrapper 2.02")]library OPCAutomation{    importlib("stdole32.tlb");    importlib("stdole2.tlb");    //==========================================================================    // Enumerations    enum OPCNamespaceTypes     {         OPCHierarchical = 1,         OPCFlat    };    enum OPCDataSource     {         OPCCache = 1,         OPCDevice    };    enum OPCAccessRights     {         OPCReadable = 1,         OPCWritable    };    enum OPCServerState    {         OPCRunning = 1,         OPCFailed,        OPCNoconfig,         OPCSuspended,        OPCTest,         OPCDisconnected     };    //==========================================================================    // IOPCAutoServer    [        object,        dual,oleautomation,        uuid(28E68F92-8D75-11d1-8DC3-3C302A000000),        helpstring("OPCServer Object"),        pointer_default(unique)    ]    interface IOPCAutoServer : IDispatch    {        //======================================================================        // Properties    };    //==========================================================================    // DIOPCServerEvent    [        uuid(28E68F93-8D75-11d1-8DC3-3C302A000000),        nonextensible,        helpstring("OPC Server Event")    ]    dispinterface DIOPCServerEvent    {        properties:        methods:                [id(1)]         void ServerShutDown(            [in,string] BSTR Reason         );    };    //==========================================================================    // OPCBrowser    [        object,        dual, oleautomation,        uuid(28E68F94-8D75-11d1-8DC3-3C302A000000),        helpstring("OPC Browser"),        pointer_default(unique)    ]    interface OPCBrowser : IDispatch    {            };    //==========================================================================    // IOPCGroups    [        object,        dual,oleautomation,        uuid(28E68F95-8D75-11d1-8DC3-3C302A000000),        helpstring("Collection of OPC Group objects"),        pointer_default(unique)    ]    interface IOPCGroups : IDispatch    {        //======================================================================        // Properties    };    //==========================================================================    // DIOPCGroupsEvent    [        uuid(28E68F9D-8D75-11d1-8DC3-3C302A000000),        nonextensible,        helpstring("OPC Groups Event")    ]    dispinterface DIOPCGroupsEvent    {        properties:        methods:                [id(1)]         void GlobalDataChange(            [in] LONG                TransactionID,            [in] LONG                GroupHandle,            [in] LONG                NumItems,            [in] SAFEARRAY(LONG)  *  ClientHandles,            [in] SAFEARRAY(VARIANT)* ItemValues,            [in] SAFEARRAY(LONG)*    Qualities,            [in] SAFEARRAY(DATE)*    TimeStamps        );    };    //==========================================================================    // IOPCGroup    [        object,        dual,oleautomation,        uuid(28E68F96-8D75-11d1-8DC3-3C302A000000),        helpstring("OPC Group Object"),        pointer_default(unique)    ]    interface IOPCGroup : IDispatch    {        //======================================================================        // Properties                                    };    //==========================================================================    // DIOPCGroupEvent    [        uuid(28E68F97-8D75-11d1-8DC3-3C302A000000),        nonextensible,        helpstring("OPC Group Events")    ]    dispinterface DIOPCGroupEvent    {        properties:        methods:        [id(1)]         void DataChange(            [in] LONG                TransactionID,            [in] LONG                NumItems,            [in] SAFEARRAY(LONG)*    ClientHandles,            [in] SAFEARRAY(VARIANT)* ItemValues,            [in] SAFEARRAY(LONG)*    Qualities,            [in] SAFEARRAY(DATE)*    TimeStamps        );        [id(2)]         void AsyncReadComplete(            [in] LONG                TransactionID,            [in] LONG                NumItems,            [in] SAFEARRAY(LONG)*    ClientHandles,            [in] SAFEARRAY(VARIANT)* ItemValues,            [in] SAFEARRAY(LONG)*    Qualities,            [in] SAFEARRAY(DATE)*    TimeStamps,            [in] SAFEARRAY(LONG)*    Errors        );        [id(3)]         void AsyncWriteComplete(            [in] LONG             TransactionID,            [in] LONG             NumItems,            [in] SAFEARRAY(LONG)* ClientHandles,            [in] SAFEARRAY(LONG)* Errors        );        [id(4)]         void AsyncCancelComplete(            [in] LONG CancelID        );    };    //==========================================================================    // OPCItems    [        object,        dual,oleautomation,        uuid(28E68F98-8D75-11d1-8DC3-3C302A000000),        helpstring("Collection of OPC Item objects"),        pointer_default(unique)    ]    interface OPCItems : IDispatch    {        //======================================================================        // Properties           };    //==========================================================================    // OPCItem    [        object,        dual,oleautomation,        uuid(28E68F99-8D75-11d1-8DC3-3C302A000000),        helpstring("OPC Item object"),        pointer_default(unique)    ]    interface OPCItem : IDispatch    {        //======================================================================        // Properties            };    //==========================================================================    // IOPCActivator    [        object,        dual,oleautomation,        uuid(860A4800-46A4-478b-A776-7F3A019369E3),        helpstring("Used to associate existing COM servers with a OPCAutoServer object."),        pointer_default(unique)    ]    interface IOPCActivator : IDispatch    {        //======================================================================        // Methods        [helpstring("Returns an automation wrapper instance for an server existing COM server.")]        HRESULT Attach(            [in]           IUnknown*        Server,            [in, string]   BSTR             ProgID,            [in, optional] VARIANT          NodeName,            [out, retval]  IOPCAutoServer** ppWrapper         );    };    //==========================================================================    // OPCActivator        [        uuid(860A4801-46A4-478b-A776-7F3A019369E3),        helpstring("OPC Automation Server Activator")    ]    coclass OPCActivator    {        [default] interface IOPCActivator;    };    //==========================================================================    // OPCServer        [        uuid(28E68F9A-8D75-11d1-8DC3-3C302A000000),        helpstring("OPC Automation Server")    ]    coclass OPCServer    {        [default]         interface IOPCAutoServer;        [source, default] dispinterface DIOPCServerEvent;    };    //==========================================================================    // OPCGroups    [        uuid(28E68F9E-8D75-11d1-8DC3-3C302A000000),        helpstring("OPC Automation Groups Collection")    ]    coclass OPCGroups    {        [default]         interface IOPCGroups;        [source, default] dispinterface DIOPCGroupsEvent;    };    //==========================================================================    // OPCGroup    [        uuid(28E68F9B-8D75-11d1-8DC3-3C302A000000),        helpstring("OPC Automation Group")    ]    coclass OPCGroup    {        [default]         interface IOPCGroup;        [source, default] dispinterface DIOPCGroupEvent;    };};

共有1个答案

夹谷野
2023-08-02

coclass 或者 interface 的 uuid 属性里定义:

[    object,    uuid(28E68F92-8D75-11d1-8DC3-3C302A000000),  // 这就是一个 IID    helpstring("OPCServer Object"),    pointer_default(unique)]interface IOPCAutoServer : IDispatch{    // ...};

28E68F92-8D75-11d1-8DC3-3C302A000000 就是 IOPCAutoServer 接口的 IID。

CLSID,一般在 coclass 的 uuid 属性里定义:

[    uuid(860A4801-46A4-478b-A776-7F3A019369E3),  // 这就是一个 CLSID    helpstring("OPC Automation Server Activator")]coclass OPCActivator{    // ...};

860A4801-46A4-478b-A776-7F3A019369E3 就是 OPCActivator 类的 CLSID。

 类似资料: