你好轻舞肥羊,如何把WinServerName改为EXE文件名,工程文件如下program sSvr;uses Forms, SysUtils, Windows, SvcMgr, WinSvc, Main in 'Main.pas' {Frm_main};{$R *.res}function Installing: Boolean; //安装后卸载服务begin Result := FindCmdLineSwitch('INSTALL',['-','/','/'], True) or FindCmdLineSwitch('UNINSTALL',['-','/','/'], True);end;function IfStartService: Boolean; //假如开始服务var Mgr, Svc: Integer; UserName, ServiceStartName: string; Config: Pointer; Size: DWord;begin Result := False; Mgr := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS); if Mgr <> 0 then begin Svc := OpenService(Mgr, PChar([red]WinServerName[/red]), SERVICE_ALL_ACCESS); Result := Svc <> 0; if Result then begin QueryServiceConfig(Svc, nil, 0, Size); Config := AllocMem(Size); try QueryServiceConfig(Svc, Config, Size, Size); ServiceStartName := PQueryServiceConfig(Config)^.lpServiceStartName; if CompareText(ServiceStartName, 'LocalSystem') = 0 then ServiceStartName := 'SYSTEM'; finally Dispose(Config); end; CloseServiceHandle(Svc); end; CloseServiceHandle(Mgr); end; if Result then begin Size := 256; SetLength(UserName, Size); GetUserName(PChar(UserName), Size); SetLength(UserName, StrLen(PChar(UserName))); Result := CompareText(UserName, ServiceStartName) = 0; end;end; begin if Installing or IfStartService then begin SvcMgr.Application.Initialize; LiveService := TLiveService.CreateNew(SvcMgr.Application,0); SvcMgr.Application.CreateForm(TFrm_main, Frm_main); SvcMgr.Application.Run; end;end.