program Project2;uses SvcMgr, SysUtils, Forms, Unit1 in 'Unit1.pas' {Service1: TService}, Unit2 in 'Unit2.pas' {Form2};{$R *.RES} var i : Integer; IsService : Boolean; begin IsService := False; for i:=1 to ParamCount-1 do begin if SameText(ParamStr(i),'Service') then begin IsService := True; Break; end; end; if IsService then begin SvcMgr.Application.Initialize; SvcMgr.Application.CreateForm(TService1, Service1); SvcMgr.Application.Run; end else begin Forms.Application.Initialize; Forms.Application.CreateForm(TForm2,Form2); Forms.Application.Run; end;end.
SvcMgr,
SysUtils,
Forms,
Unit1 in 'Unit1.pas' {Service1: TService},
Unit2 in 'Unit2.pas' {Form2};{$R *.RES}
var
i : Integer;
IsService : Boolean;
begin
IsService := False;
for i:=1 to ParamCount-1 do
begin
if SameText(ParamStr(i),'Service') then
begin
IsService := True;
Break;
end;
end; if IsService then
begin
SvcMgr.Application.Initialize;
SvcMgr.Application.CreateForm(TService1, Service1);
SvcMgr.Application.Run;
end
else
begin
Forms.Application.Initialize;
Forms.Application.CreateForm(TForm2,Form2);
Forms.Application.Run;
end;end.
如果不加命令行参数,在主程序里面自动判断,该怎么做?