delphi 利用命令参数启动
Unit: System
Category: Command Line Utilities
Function: ParamCount and ParamStr.
Example:
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
for i := 1 to ParamCount do
begin
if LowerCase(ParamStr(i)) = 'beep' then
Beep(10000,1000)
else if (LowerCase(ParamStr(i)) = 'exit' then
Application.Terminate;
end;
end;
因为命令行本身也是一个参数
如:
xxx.exe a b c
实际上是四个(0-3)参数,第0个参数是"xxx.exe",我们要的是第1个。