OPC Studio User's Guide and Reference
Importing Type Libraries in Visual C++
Client and Subscriber Development > Development Fundamentals > Referencing the Components (COM) > Importing Type Libraries in Visual C++

There are several ways to consume the OPC Data Client component in Microsoft Visual C++. One of the easiest is to use the Compiler COM Support. This is done by placing #import directives into your code; the directives reference the OPC Data Client type libraries. The compiler converts the type libraries into C++ header files that describe the COM interfaces.

You can place the #import directives in your code one by one, but you can also simply #include a QuickOpc.h file provided with the product in the SDK\include subdirectory. This file imports all OPC Data Client type libraries and declares wrappers for OPC Data Client interfaces and classes. Its content is as follows:

// $Header: $
// Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
// This files imports all QuickOPC libraries (and system libraries they require), creating Compiler COM Support wrappers.
// It also contains additional definitions for creating event sinks.
#pragma once



// #import system libraries

// mscorlib
#pragma warning(push)
#pragma warning(disable:4278)    // 'ReportEvent': identifier in type library 'BED7F4EA-1A96-11D2-8F08-00A0C9A6186D' is already a macro; use the 'rename' qualifier
#if _MSC_VER >= 1300
#define IMPORT_MSCORLIB "libid:BED7F4EA-1A96-11D2-8F08-00A0C9A6186D" \
    rename("or", "or1")
#else
#define IMPORT_MSCORLIB "mscorlib.tlb"
#endif
#import IMPORT_MSCORLIB
#pragma warning(pop)
using namespace mscorlib;

// System.Drawing
#if _MSC_VER >= 1300
#define IMPORT_SYSTEM_DRAWING "libid:D37E2A3E-8545-3A39-9F4F-31827C9124AB"
#else
#define IMPORT_SYSTEM_DRAWING "System.Drawing.tlb"
#endif
#import IMPORT_SYSTEM_DRAWING
using namespace System_Drawing;

// System.Windows.Forms
#pragma warning(push)
#pragma warning(disable:4192)    // automatically excluding 'IDataObject' while importing type library 'System.Windows.Forms.tlb'
#if _MSC_VER >= 1300
#define IMPORT_SYSTEM_WINDOWS_FORMS "libid:215D64D2-031C-33C7-96E3-61794CD1EE61"
#else
#define IMPORT_SYSTEM_WINDOWS_FORMS "System.Windows.Forms.tlb"
#endif
#import IMPORT_SYSTEM_WINDOWS_FORMS
#pragma warning(pop)
using namespace System_Windows_Forms;



// #import QuickOPC libraries

// OpcLabs.BaseLib
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_BASELIB    "libid:ecf2e77d-3a90-4fb8-b0e2-f529f0cae9c9"
#else
#define IMPORT_OPCLABS_BASELIB    "OpcLabs.BaseLib.tlb"
#endif
#import IMPORT_OPCLABS_BASELIB \
    rename("password", "Password") \
    rename("value", "Value")
using namespace OpcLabs_BaseLib;

// OpcLabs.BaseLibComponents
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_BASELIBCOMPONENTS    "libid:1F127C9A-7FB7-4F5E-BCF6-64339872A64B"
#else
#define IMPORT_OPCLABS_BASELIBCOMPONENTS    "OpcLabs.BaseLibComponents.tlb"
#endif
#import IMPORT_OPCLABS_BASELIBCOMPONENTS
using namespace OpcLabs_BaseLibComponents;

// OpcLabs.BaseLibForms
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_BASELIBFORMS    "libid:A0D7CA1E-7D8C-4D31-8ECB-84929E77E331"
#else
#define IMPORT_OPCLABS_BASELIBFORMS    "OpcLabs.BaseLibForms.tlb"
#endif
#import IMPORT_OPCLABS_BASELIBFORMS
using namespace OpcLabs_BaseLibForms;

// OpcLabs.EasyOpcClassicCore
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_EASYOPCCLASSICCORE    "libid:1F457B45-A4E0-4A92-928F-D1D1ACB67C54"
#else
#define IMPORT_OPCLABS_EASYOPCCLASSICCORE    "OpcLabs.EasyOpcClassicCore.tlb"
#endif
#import IMPORT_OPCLABS_EASYOPCCLASSICCORE \
    rename("itemId", "ItemId") \
    rename("machineName", "MachineName") \
    rename("requestedUpdateRate", "RequestedUpdateRate") \
    rename("serverClass", "ServerClass")
using namespace OpcLabs_EasyOpcClassicCore;

// OpcLabs.EasyOpcClassic
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_EASYOPCCLASSIC    "libid:1F165598-2F77-41C8-A9F9-EAF00C943F9F"
#else
#define IMPORT_OPCLABS_EASYOPCCLASSIC    "OpcLabs.EasyOpcClassic.tlb"
#endif
#import IMPORT_OPCLABS_EASYOPCCLASSIC \
    rename("itemId", "ItemId") \
    rename("machineName", "MachineName") \
    rename("requestedUpdateRate", "RequestedUpdateRate") \
    rename("serverClass", "ServerClass")
using namespace OpcLabs_EasyOpcClassic;

// OpcLabs.EasyOpcClassicComponents
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_EASYOPCCLASSICCOMPONENTS    "libid:A03AA108-3C6B-4CB0-A813-BCBBCD335DAE"
#else
#define IMPORT_OPCLABS_EASYOPCCLASSICCOMPONENTS    "OpcLabs.EasyOpcClassicComponents.tlb"
#endif
#import IMPORT_OPCLABS_EASYOPCCLASSICCOMPONENTS
using namespace OpcLabs_EasyOpcClassicComponents;

// OpcLabs.EasyOpcUA
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_EASYOPCUA    "libid:E15CAAE0-617E-49C6-BB42-B521F9DF3983"
#else
#define IMPORT_OPCLABS_EASYOPCUA    "OpcLabs.EasyOpcUA.tlb"
#endif
#import IMPORT_OPCLABS_EASYOPCUA \
    rename("applicationUriString", "ApplicationUriString") \
    rename("attributeData", "AttributeData") \
    rename("browsePath", "BrowsePath") \
    rename("endpointDescriptor", "EndpointDescriptor") \
    rename("expandedText", "ExpandedText") \
    rename("inputArguments", "InputArguments") \
    rename("inputTypeCodes", "InputTypeCodes") \
    rename("nodeDescriptor", "NodeDescriptor") \
    rename("nodeId", "NodeId") \
    rename("password", "Password") \
    rename("samplingInterval", "SamplingInterval") \
    rename("serverCapabilities", "ServerCapabilities") \
    rename("value", "Value")
using namespace OpcLabs_EasyOpcUA;

// OpcLabs.EasyOpcUAComponents
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_EASYOPCUACOMPONENTS    "libid:5346E434-17C3-4D23-AD1F-43F7B92B2468"
#else
#define IMPORT_OPCLABS_EASYOPCUACOMPONENTS    "OpcLabs.EasyOpcUAComponents.tlb"
#endif
#import IMPORT_OPCLABS_EASYOPCUACOMPONENTS
using namespace OpcLabs_EasyOpcUAComponents;

// OpcLabs.EasyOpcForms
#if _MSC_VER >= 1300
#define IMPORT_OPCLABS_EASYOPCFORMS    "libid:2C654FA0-6CD6-496D-A64E-CE2D2925F388"
#else
#define IMPORT_OPCLABS_EASYOPCFORMS    "OpcLabs.EasyOpcForms.tlb"
#endif
#import IMPORT_OPCLABS_EASYOPCFORMS
using namespace OpcLabs_EasyOpcForms;



// DISPID-s

// CertificateSecurityHandlerEvents
#define DISPID_CERTIFICATESECURITYHANDLEREVENTS_GETLOCALCERTIFICATES 1001
#define DISPID_CERTIFICATESECURITYHANDLEREVENTS_VALIDATEREMOTECERTIFICATE 1003


// EasyAEClientEvents
#define DISPID_EASYAECLIENTEVENTS_EVENTINGFAILURE 1001
#define DISPID_EASYAECLIENTEVENTS_NOTIFICATION 1002

// EasyAEClientManagementEvents
#define DISPID_EASYAECLIENTMANAGEMENTEVENTS_LOGENTRY    1001

// EasyDAClientEvents
#define DISPID_EASYDACLIENTEVENTS_EVENTINGFAILURE 1001
#define DISPID_EASYDACLIENTEVENTS_ITEMCHANGED 1002

// EasyDAClientManagementEvents
#define DISPID_EASYDACLIENTMANAGEMENTEVENTS_LOGENTRY    1001


// EasyUAClientConnectionMonitoringEvents
#define DISPID_EASYUACLIENTCONNECTIONMONITORINGEVENTS_SERVERCONDITIONCHANGED  1001

// EasyUAClientEvents
#define DISPID_EASYUACLIENTEVENTS_DATACHANGENOTIFICATION  1001
#define DISPID_EASYUACLIENTEVENTS_EVENTINGFAILURE  1002
#define DISPID_EASYUACLIENTEVENTS_EVENTNOTIFICATION  1003

// EasyUAClientManagementEvents
#define DISPID_EASYUACLIENTMANAGEMENTEVENTS_LOGENTRY    1001

// EasyUAClientServerApplicationEvents
#define DISPID_EASYUACLIENTSERVERAPPLICATIONEVENTS_PRIVATEKEYPASSWORDCHANGED    1001

// EasyUASubscriberEvents
#define DISPID_EASYUASUBSCRIBEREVENTS_DATASETMESSAGE  1001
#define DISPID_EASYUASUBSCRIBEREVENTS_EVENTINGFAILURE  1002
#define DISPID_EASYUASUBSCRIBEREVENTS_RESOLVERACCESS  1003
#define DISPID_EASYUASUBSCRIBEREVENTS_SUBSCRIPTIONRESOLVED  1004

// EasyUASubscriberManagementEvents
#define DISPID_EASYUASUBSCRIBERMANAGEMENTEVENTS_LOGENTRY    1001

 

 The file also makes sure (using the rename attributes) that the symbols are properly cased, and adds useful #define-s for defining event sinks.

 

See Also