在程序中导入了一个OCX控件,其中使用的参数为如下两个:
function receiveMessage(var NetID: Smallint; var NodeID: Smallint; var UnitID: Smallint;
MessageType: OleVariant): OleVariant;
function sendFinsCommand(NetID: Smallint; NodeID: Smallint; UnitID: Smallint;
Message: OleVariant): Integer; overload;编写程序为:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, DBOleCtl, FINSMSGCTLLib_TLB;type
TForm1 = class(TForm)
fnsmsg1: TFinsMsg;
btn1: TButton;
edt1: TEdit;
procedure btn1Click(Sender: TObject);
procedure fnsmsg1Receive(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);
begin
fnsmsg1.sendFinsCommand(0,2,0,'0701');
end;procedure TForm1.fnsmsg1Receive(Sender: TObject);
var
a,b,c:SmallInt;
messagefins:OleVariant;
s:string;
begin
a:=0;
b:=2;
c:=0;
s := fnsmsg1.receiveMessage(a,b,c,messagefins);
end;end.单击“btn1",程序执行,发送指令:fnsmsg1.sendFinsCommand(0,2,0,'0701');顺序执行。控件接收到指令后,开始自动运行fnsmsg1Receive函数,到 s := fnsmsg1.receiveMessage(a,b,c,messagefins);行,系统抛出如下错误:
Project Project1.exe raised exception class EOleException with message "Unsupported Variant Type on the Method argument".Process stopped.
我把messagefins变为String类型也是一样的。
请大神给出较为详细的分析,最好能给出点吗,谢谢!
function receiveMessage(var NetID: Smallint; var NodeID: Smallint; var UnitID: Smallint;
MessageType: OleVariant): OleVariant;
function sendFinsCommand(NetID: Smallint; NodeID: Smallint; UnitID: Smallint;
Message: OleVariant): Integer; overload;编写程序为:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, DBOleCtl, FINSMSGCTLLib_TLB;type
TForm1 = class(TForm)
fnsmsg1: TFinsMsg;
btn1: TButton;
edt1: TEdit;
procedure btn1Click(Sender: TObject);
procedure fnsmsg1Receive(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);
begin
fnsmsg1.sendFinsCommand(0,2,0,'0701');
end;procedure TForm1.fnsmsg1Receive(Sender: TObject);
var
a,b,c:SmallInt;
messagefins:OleVariant;
s:string;
begin
a:=0;
b:=2;
c:=0;
s := fnsmsg1.receiveMessage(a,b,c,messagefins);
end;end.单击“btn1",程序执行,发送指令:fnsmsg1.sendFinsCommand(0,2,0,'0701');顺序执行。控件接收到指令后,开始自动运行fnsmsg1Receive函数,到 s := fnsmsg1.receiveMessage(a,b,c,messagefins);行,系统抛出如下错误:
Project Project1.exe raised exception class EOleException with message "Unsupported Variant Type on the Method argument".Process stopped.
我把messagefins变为String类型也是一样的。
请大神给出较为详细的分析,最好能给出点吗,谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货