zoukankan      html  css  js  c++  java
  • OPC客户端设计

    1. 开发环境配置

      要安装和开发OPC程序,安装必要的OPC代理/存根(Proxy/Stub)DLL是必需的,这些文件提供了OPC接口的数据结构定义,可以使OPC客户端程序和服务器程序之间进行有效的通信。

      所有文件必须安装在客户端机器和服务器端机器上。要将这些文件放置在system32系统文件夹下。

    需要文件:

      这些文件包括:

      opc_aeps.dll    //警报与时间服务器代理/存根

      opccomn_ps.dll   //公用的代理/存根(主要服务器都需要)

      opchda_ps.dll   //历史数据存取代理/存根

      aprxdist.exe     //运行环境需要

      opcenum.exe      //服务器类别搜索组建程序(都需要),如果没有,就无法在注册表中进行注册

    安装方法:

      将上述文件全部复制到windows\system32目录下。

      安装代理/存根:

        REGSVR32 opcproxy.dll

        REGSVR32 opccomn_ps.dll

        REGSVR32 opc_aeps.dll

        REGSVR32 opchda_ps.dll

      安装opcenum.exe

        opcenum /regserver

     

    //CComPtr: Smart pointer

    CComPtr<IOPCServerList> pOPCServerList;

    //Creates a single uninitialized object of the class associated with a specified CLSID.
    hr = pOPCServerList.CoCreateInstance( CLSID_OpcServerList );

    //A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.

    //to register, you need to run opcenum.exe

    if(REGDB_E_CLASSNOTREG == hr)
      return FALSE;

    if( FAILED( hr ) )
      return FALSE;

    The return value of function CoCreateInstance:
     
    ValueDescription

    S_OK

    An instance of the specified object class was successfully created.

    REGDB_E_CLASSNOTREG

    A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.

    CLASS_E_NOAGGREGATION

    This class cannot be created as part of an aggregate.

  • 相关阅读:
    用c#小程序理解线程
    我对线程入门理解
    网站发布后IIS故障解决办法
    ASP .NET XML 文件
    SortedList 对象兼有 ArrayList 和 Hashtable 对象的特性。
    (笔记)索引器
    HOW TO:使用 Visual C# .NET 在 ASP.NET 中创建自定义错误报告
    读取EXCEL的数据到datagridview
    一个超级简单的文件流操作WINDOW应用程序
    Gridview事件
  • 原文地址:https://www.cnblogs.com/johnpher/p/2720218.html
Copyright © 2011-2022 走看看