T
taiyuntao
Unregistered / Unconfirmed
GUEST, unregistred user!
最近做了一个OPC客户端,用的是OPC基金会发布的OPCDAAUTO.DLL,调用同步读和同步写方法正常,但一调用异步读时提示Oleerror 80040200:
OPCAutomation_TLB.pas中方法声明:
procedure AsyncRead(NumItems: Integer; var ServerHandles: PSafeArray; out Errors: PSafeArray;TransactionID: Integer; out CancelID: Integer);
我的代码如下:
procedure TForm1.asynreadClick(Sender: TObject);
var
o_server_handle, o_err: Variant;
Id,i: Integer;
QuXiaoId:Integer;
liststr:String;
begin
o_err := VarArrayCreate([0,serverhandlelist.Count-1], VarInteger);
o_server_handle := VarArrayCreate([0,serverhandlelist.Count-1], VarInteger);
for i:=0 to serverhandlelist.Count-1 do begin
Id:=Pos('*',serverhandlelist.Strings);
liststr:=copy(serverhandlelist.Strings,1,id-1);
o_server_handle:=StrToInt(liststr);
Memo1.Lines.Add(liststr);
end;
OPCGroup1.IsActive:=True;
OPCGroup1.AsyncRead(OPCItems1.Count,PSafeArray(TVarData(o_server_handle).VArray),
PSafeArray(TVarData(o_err).VInteger),100,QuXiaoId);
end;
实在是急,求哪位帮忙解决
OPCAutomation_TLB.pas中方法声明:
procedure AsyncRead(NumItems: Integer; var ServerHandles: PSafeArray; out Errors: PSafeArray;TransactionID: Integer; out CancelID: Integer);
我的代码如下:
procedure TForm1.asynreadClick(Sender: TObject);
var
o_server_handle, o_err: Variant;
Id,i: Integer;
QuXiaoId:Integer;
liststr:String;
begin
o_err := VarArrayCreate([0,serverhandlelist.Count-1], VarInteger);
o_server_handle := VarArrayCreate([0,serverhandlelist.Count-1], VarInteger);
for i:=0 to serverhandlelist.Count-1 do begin
Id:=Pos('*',serverhandlelist.Strings);
liststr:=copy(serverhandlelist.Strings,1,id-1);
o_server_handle:=StrToInt(liststr);
Memo1.Lines.Add(liststr);
end;
OPCGroup1.IsActive:=True;
OPCGroup1.AsyncRead(OPCItems1.Count,PSafeArray(TVarData(o_server_handle).VArray),
PSafeArray(TVarData(o_err).VInteger),100,QuXiaoId);
end;
实在是急,求哪位帮忙解决