既能当普通应用程序执行,又可以做系统service执行?
可以实现吗?

解决方案 »

  1.   

    可以,mysql就是这样作的.它有源码(不过是用C写的)
      

  2.   

    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.
      

  3.   

    sdzeng(大头鸟) 的是有命令行参数的。
    如果不加命令行参数,在主程序里面自动判断,该怎么做?
      

  4.   

    参数Delphi安装目录:Borland\Delphi6\Source\Vcl\ScktSrvr.dpr