嘻嘻,新年来拿分了,D7+WinXP下测试通过
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
parampath : String;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
//ParamStr()就是取得参数。
//像这个例子:i:/a/Project1.exe /a /b /c
// ParamStr(1)得到的就是 /a
// ParamStr(2)得到的就是 /b
// ParamStr(3)得到的就是 /c
ParamPath:=LowerCase(ParamStr(1));
if Parampath ='/a' then
Button1Click(nil)
else if Parampath='/b' then
Button2Click(nil);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage('传入的参数是'+parampath);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage('传入的参数是'+parampath);
end;
end.