老是提示"Unsatisfied forward or external declaration: 'TForm1.executefile'",这参数要怎么写啊!
unit Unit1;interfaceuses
  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.

解决方案 »

  1.   

    executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle把const去掉试试
      

  2.   

    executefile写错位置了吧,写到private下,然后ctrl+shift+c一下,
      

  3.   

    参数没有错误,是程序找不到类TFrom1中定义的函数的入口,因为你的函数是在TForm1中定义的,所以在下面的实现部分必须这样写:
    function TForm1.executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
    var
    zfilename,zparams,zdir:array[0..5] of char;
    begin
      ……
    end;
      

  4.   

    unit Unit1;interfaceuses
      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.