2024年4月5日发(作者:)

delphi 用Automation接口编写OPC客户端

一,首先是OPCAutomation 的安装

1)使用regsvr32 注册

2)在 Delphi 的project菜单中,选导入类型库 OPC Automation 2.0。

二 编写程序

声明 OPC 的类与接口

FOPCServer:TOPCServer;

FOPCGroup :TOPCGroup;

FOPCb :OPCBrowser;

FOPCItems :OPCItems; // interface

FOPCItem :OPCItem; // interface

// 获取OPC Server 列表

function verList(): Boolean;

var OPCServerList,OPCServerName:OleVariant;

j,i:integer;

begin

Result := false;

try

FOPCServer := (Self);