关于形参和实参不一致的问题

minipig520 2011-11-24 04:29:35
procedure TMainForm.Button9Click(Sender: TObject);
var
s: integer ;
begin
s := strtoint(ComboBox8.Text)*32 + strtoint(ComboBox9.Text) ;
if ComboBox8.Text='' then
begin
ShowMessage('Please select Projector ID');
exit;
end;
if not switchchanel_video(s,4,'')//这里报错
then ShowMessage('Divide error');
end;
这个是用来调用DLL的
声明如下
function switchchanel_video(maxinputchannel,maxoutputchannel:integer; var sendstring:pchar):integer;stdcall;
function switchchanel_video;stdcall; external DLLName;


这到底怎么不一致了啊 最后一个参数我要为空
...全文
394 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
minipig520 2011-11-24
  • 打赏
  • 举报
回复
procedure TMainForm.Button9Click(Sender: TObject);
var
s,ret: integer ;
temp : PChar;
begin
temp := PChar('') ;
s := strtoint(ComboBox8.Text)*32 + strtoint(ComboBox9.Text) ;
if ComboBox8.Text='' then
begin
ShowMessage('Please select Projector ID');
exit;
end;
if ComboBox9.Text='' then
begin
ShowMessage('Please select Projector ID');
exit;
end;
ret := switchchanel_video(s,4,temp);
if ret = 0
then ShowMessage('Divide error');
end;


这样编译是没有问题了,但为什么运行到下面begin就停止了?
begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
minipig520 2011-11-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 csn168 的回复:]
定义一个临时变量 将它复制为空 然后传这个变量到函数里

procedure TMainForm.Button9Click(Sender: TObject);
var
s: integer ;
tmpp: PChar;
begin
tmpp := PChar('');
s := strtoint(ComboBox8.Text)*32 + strtoint(Combo……
[/Quote]
[ERROR]typeexpression must be BOLLEAN 错误指向showmessage
[Fatal Error] Could not compile used unit 'BD100TEST.pas'
minipig520 2011-11-24
  • 打赏
  • 举报
回复
是啊 还多了错误提示 说showmessage那要用布尔类型
csn168 2011-11-24
  • 打赏
  • 举报
回复
定义一个临时变量 将它复制为空 然后传这个变量到函数里

procedure TMainForm.Button9Click(Sender: TObject);
var
s: integer ;
tmpp: PChar;
begin
tmpp := PChar('');
s := strtoint(ComboBox8.Text)*32 + strtoint(ComboBox9.Text) ;
if ComboBox8.Text='' then
begin
ShowMessage('Please select Projector ID');
exit;
end;
if not switchchanel_video(s,4,tmpp )
then ShowMessage('Divide error');
end;
爱蹄子的羊头 2011-11-24
  • 打赏
  • 举报
回复
换成 NIL 还错?
minipig520 2011-11-24
  • 打赏
  • 举报
回复
不行哦 用‘’时提示 types of actual and formal var parameters must be identical
爱蹄子的羊头 2011-11-24
  • 打赏
  • 举报
回复
if not switchchanel_video(s,4,nil)

试试?

16,747

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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