参数写错了吗?

zhong198801 2009-10-27 03:05:52
老是提示"Unsatisfied forward or external declaration: 'TForm1.executefile'",这参数要怎么写啊!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,shellapi;

type
TForm1 = class(TForm)
zj: TComboBox;
gq: TComboBox;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure zjChange(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
function executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
filename,path:string;
implementation

{$R *.dfm}
procedure TForm1.zjChange(Sender: TObject);
begin
case zj.ItemIndex of
0,1,2:path:='h:\a'+inttostr(zj.ItemIndex +1);
3,4,5:path:='h:\b'+inttostr(zj.ItemIndex +1);
end;
filename:=inttostr(zj.itemindex+1)+'.txt';
gq.Items.LoadFromFile (filename);
gq.Text:=gq.Items.Strings [0];
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
case gq.ItemIndex of
0,1,2:filename:=path+'\'+'0'+inttostr(gq.ItemIndex +1)+'.mp3';
3,4,5:filename:=path+'\'+'mp3';
else
filename:=path+'\a.mp3';
end;
executefile('wmplayer.exe','','C:\Program Files\Windows Media Player ',sw_hide);
end;
function executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
var
zfilename,zparams,zdir:array[0..5] of char;
begin
result:=shellexecute(application.MainForm .handle,nil,
strpcopy(zfilename,filename),strpcopy(zparams,params),
strpcopy(zdir,defaultdir),showcmd);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;

end.
...全文
81 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhong198801 2009-10-28
  • 打赏
  • 举报
回复
我是新手,还不会玩csdn
wooden954 2009-10-27
  • 打赏
  • 举报
回复
楼主的结帖率实在太低了,有点儿对不起热心的朋友!呵呵
火龙岛主 2009-10-27
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,shellapi;

type
TForm1 = class(TForm)
zj: TComboBox;
gq: TComboBox;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure zjChange(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
function executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
filename,path:string;
implementation

{$R *.dfm}
procedure TForm1.zjChange(Sender: TObject);
begin
case zj.ItemIndex of
0,1,2:path:='h:\a'+inttostr(zj.ItemIndex +1);
3,4,5:path:='h:\b'+inttostr(zj.ItemIndex +1);
end;
filename:=inttostr(zj.itemindex+1)+'.txt';
gq.Items.LoadFromFile (filename);
gq.Text:=gq.Items.Strings [0];
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
case gq.ItemIndex of
0,1,2:filename:=path+'\'+'0'+inttostr(gq.ItemIndex +1)+'.mp3';
3,4,5:filename:=path+'\'+'mp3';
else
filename:=path+'\a.mp3';
end;
executefile('wmplayer.exe','','C:\Program Files\Windows Media Player ',sw_hide);
end;
function Tform1.executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
var
zfilename,zparams,zdir:array[0..5] of char;
begin
result:=shellexecute(application.MainForm .handle,nil,
strpcopy(zfilename,filename),strpcopy(zparams,params),
strpcopy(zdir,defaultdir),showcmd);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;

end.
wooden954 2009-10-27
  • 打赏
  • 举报
回复
参数没有错误,是程序找不到类TFrom1中定义的函数的入口,因为你的函数是在TForm1中定义的,所以在下面的实现部分必须这样写:
function TForm1.executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
var
zfilename,zparams,zdir:array[0..5] of char;
begin
……
end;
gwhdaxia 2009-10-27
  • 打赏
  • 举报
回复
executefile写错位置了吧,写到private下,然后ctrl+shift+c一下,
iseekcode 2009-10-27
  • 打赏
  • 举报
回复
executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle

把const去掉试试
suuuu 2009-10-27
  • 打赏
  • 举报
回复
赶紧结完贴再发问吧,不然人都给整没有了。。。
可以把List传递给一个接受List参数的方法吗? 可以把List传递给一个接受List参数的方法吗?  [复制链接] jiangweibin2573 该用户从未签到 13 黑马币 25 技术分 11 主题 中级黑马 发消息 电梯直达 楼主

5,388

社区成员

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

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