读取OleVariant参数内容,报错!

shq_cpst 2015-03-18 02:38:01
在程序中导入了一个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;

interface

uses
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类型也是一样的。
请大神给出较为详细的分析,最好能给出点吗,谢谢!


...全文
111 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yct0605 2015-03-18
  • 打赏
  • 举报
回复
试试 s := fnsmsg1.receiveMessage(0,2,0,'0701'); 可有错误!
yct0605 2015-03-18
  • 打赏
  • 举报
回复
messagefins的值是多少,从代码上看,a,b,c都有赋值,messagefins没有赋值?

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧