//我服了你。
//paramstr(0)表示程序自己,paramstr(1)是第一个命令行参数
//看看下面程序,开一个DOS窗口(或者在"运行"处)
//执行project1 文件名.txt可以得到结果
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
if FileExists(paramstr(1)) and (copy(paramstr(1),length(paramstr(1))-3,4)='.txt') then
memo1.Lines.LoadFromFile(paramstr(1));
end;
end.