delphi 7 opc客户端编程问题 点击:698 | 回复:0



tangzhj

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 2回
  • 年度积分:0
  • 历史总积分:8
  • 注册:2006年2月09日
发表于:2006-05-18 13:46:00
楼主

在delphi 7中引入opcdaauto.dll类型库后,用以下代码执行,为何我执行代码MyOPCAutoServer:=CoOPCServer.Create;时会出错,提示内存分配访问无效,但相应vb代码正常
var
  MyOPCAutoServer : IOPCAutoServer;     //OPC服务器
  MyOPCGroups : OPCGroups;   //OPC组集合
  MyOPCGroup :  OPCGroup; //OPC组,
  MyOPCItems :  OPCItems; //OPC标签集合
begin
   MyOPCAutoServer:=CoOPCServer.Create;
   MyOPCAutoServer.Connect('ProgID','NodeName');
   MyOPCGroups:=MyOPCAutoServer.OPCGroups;
   MyOPCGroups.Set_DefaultGroupUpdateRate(500);//更新频率500ms

   MyOPCGroup:=MyOPCGroups.Add('OPCGroup');   //新添加的OPC
   MyOPCGroup.Set_IsActive(true);
   MyOPCGroup.Set_IsSubscribed(True); 
   MyOPCItems:=MyOPCGroup.OPCItems;  //建立OPC标签集合
end;


热门招聘
相关主题

官方公众号

智造工程师