Inno setup Inno安装编译器:如何安装服务

Inno setup Inno安装编译器:如何安装服务,inno-setup,Inno Setup,Inno安装我的应用程序后,我希望Inno安装2个具有windows服务列表中安装文件夹属性的服务 我已经安装了wamp,我想为apache和mysql添加一个新服务` apacheServiceInstallParams=-n万帕帕切克-k安装 mysqlServiceInstallParams=--安装手动wampmysqldc function InstallService(const FileName, ServiceName, DisplayName: string; Servi

Inno安装我的应用程序后,我希望Inno安装2个具有windows服务列表中安装文件夹属性的服务

我已经安装了
wamp
,我想为
apache
mysql添加一个新服务`

apacheServiceInstallParams=-n万帕帕切克-k安装

mysqlServiceInstallParams=--安装手动wampmysqldc

function InstallService(const FileName, ServiceName, 
  DisplayName: string; ServiceType, StartType: DWORD): Boolean;
var
  ManagerHandle: SC_HANDLE;
  ServiceHandle: SC_HANDLE;
begin
  Result := False;
  ManagerHandle := OpenSCManager('', '', SC_MANAGER_ALL_ACCESS);
  if ManagerHandle <> 0 then
  begin
    try
      ServiceHandle := CreateService(ManagerHandle, ServiceName, 
        DisplayName, SERVICE_ALL_ACCESS, ServiceType, StartType,
        SERVICE_ERROR_IGNORE, FileName, '', 0, '', '', '');
      if ServiceHandle <> 0 then
      begin
        Result := True;
        CloseServiceHandle(ServiceHandle);
      end
      else
        MsgBox(SysErrorMessage(DLLGetLastError), mbError, MB_OK);
    finally
      CloseServiceHandle(ManagerHandle);
    end;
  end
  else
    MsgBox(SysErrorMessage(DLLGetLastError), mbError, MB_OK);
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    if InstallService(ExpandConstant('{app}\bin\aoache\apache2.2.22\bin\httpd.exe'),
      'wampapachecow',
      'MySQL', SERVICE_WIN32_SHARE_PROCESS, SERVICE_AUTO_START)
    then
      MsgBox('MySql Service installation succeeded!', mbInformation, MB_OK);
    if InstallService(ExpandConstant('{app}\bin\mysql\mysql5.5.24\bin\mysqld.exe'),
      'wampmysqldcow',
      'MySQL', SERVICE_WIN32_SHARE_PROCESS, SERVICE_AUTO_START)
    then
      MsgBox('MySql Service installation succeeded!', mbInformation, MB_OK);
  end;
end;
应该是这样吗

InstallService(ExpandConstant('{app}\MySQL 5.5\bin\mysqld.exe'),
      ExpandConstant('--defaults-file="{app}\MySQL 5.5\my.ini"'),
      'MySQL', SERVICE_WIN32_SHARE_PROCESS, SERVICE_AUTO_START)
请解释第二个参数:


'wampapachecow'
ExpandConstant('--defaults file=“{app}\MySQL 5.5\my.ini”)

您可以使用以下代码创建服务,服务将自动启动

// create a system service with windows command “sc”
DosCmd := '/C '+'sc create "WCF" binPath= "'+ExpandConstant('{app}\WCF.exe' \
  type= share start= auto DisplayName= "WCF"'+' obj= '+UserName+' password= '+Passwd;
Exec(ExpandConstant('{cmd}'),DosCmd, '',  SW_HIDE,ewWaitUntilTerminated, ResultCode);

然后,WCF服务将自动启动。有关更多帮助,请在windows中运行“sc/?”

我需要检查原始代码。或者更好,我将发布一系列关于如何安装、控制和卸载服务的Q&a。[我现在很忙…]尽可能避免使用命令行工具。始终首选本机Windows API解决方案。在这种情况下,当出现问题时,您无法控制情况。谢谢,我是新手,我将继续学习INNO设置。
// create a system service with windows command “sc”
DosCmd := '/C '+'sc create "WCF" binPath= "'+ExpandConstant('{app}\WCF.exe' \
  type= share start= auto DisplayName= "WCF"'+' obj= '+UserName+' password= '+Passwd;
Exec(ExpandConstant('{cmd}'),DosCmd, '',  SW_HIDE,ewWaitUntilTerminated, ResultCode);