Commit 165cd6fb by 李定达

1.增加服务延迟启动

parent e02b03c4
...@@ -774,7 +774,7 @@ int QtServiceBase::exec() ...@@ -774,7 +774,7 @@ int QtServiceBase::exec()
{ {
if (d_ptr->args.size() > 1) { if (d_ptr->args.size() > 1) {
QString a = d_ptr->args.at(1); QString a = d_ptr->args.at(1);
if (a == QLatin1String("-i") || a == QLatin1String("-install")) { if (a == QLatin1String("-i") || a == QLatin1String("-install") || a == QLatin1String("/i") || a == QLatin1String("i")) {
if (!d_ptr->controller.isInstalled()) { if (!d_ptr->controller.isInstalled()) {
QString account; QString account;
QString password; QString password;
...@@ -818,7 +818,7 @@ int QtServiceBase::exec() ...@@ -818,7 +818,7 @@ int QtServiceBase::exec()
if (ec == -1) if (ec == -1)
qErrnoWarning("The service could not be executed."); qErrnoWarning("The service could not be executed.");
return ec; return ec;
} else if (a == QLatin1String("-t") || a == QLatin1String("-terminate")) { } else if (a == QLatin1String("-t") || a == QLatin1String("-terminate") || a == QLatin1String("/t") || a == QLatin1String("t")) {
if (!d_ptr->controller.stop()) if (!d_ptr->controller.stop())
qErrnoWarning("The service could not be stopped."); qErrnoWarning("The service could not be stopped.");
return 0; return 0;
......
...@@ -894,8 +894,11 @@ bool QtServiceBasePrivate::install(const QString &account, const QString &passwo ...@@ -894,8 +894,11 @@ bool QtServiceBasePrivate::install(const QString &account, const QString &passwo
result = true; result = true;
if (!serviceDescription.isEmpty()) { if (!serviceDescription.isEmpty()) {
SERVICE_DESCRIPTION sdesc; SERVICE_DESCRIPTION sdesc;
SERVICE_DELAYED_AUTO_START_INFO delaystart = { TRUE };
sdesc.lpDescription = (wchar_t *)serviceDescription.utf16(); sdesc.lpDescription = (wchar_t *)serviceDescription.utf16();
pChangeServiceConfig2(hService, SERVICE_CONFIG_DESCRIPTION, &sdesc); pChangeServiceConfig2(hService, SERVICE_CONFIG_DESCRIPTION, &sdesc);
pChangeServiceConfig2(hService, SERVICE_CONFIG_DELAYED_AUTO_START_INFO, &delaystart);
} }
SERVICE_FAILURE_ACTIONS servFailActions; SERVICE_FAILURE_ACTIONS servFailActions;
SC_ACTION failActions[3]; SC_ACTION failActions[3];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment