Commit fe240ba4 by 李定达

1.添加延迟启动;2.添加开机启动失败重启服务;3.添加描述信息;4.修复update.flag文件路径拼写异常;5.添加版本信息;6.测试update.flag文件

parent c35bf1f7
No preview for this file type
...@@ -210,7 +210,7 @@ void FMKeeper::onKeepProcess() ...@@ -210,7 +210,7 @@ void FMKeeper::onKeepProcess()
getimagepath(path); getimagepath(path);
flagfile = path; flagfile = path;
flagfile.append(TEXT("\\update.flag")); flagfile.append(TEXT("update.flag"));
std::cout << flagfile << std::endl; std::cout << flagfile << std::endl;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "fmwinservice.h" #include "fmwinservice.h"
#define SVCNAME TEXT("Fmupdate") #define SVCNAME TEXT("FmupdateTest")
LPCTSTR GetLastErrorMsg(DWORD dwError = 0) { LPCTSTR GetLastErrorMsg(DWORD dwError = 0) {
......
No preview for this file type
No preview for this file type
...@@ -128,6 +128,31 @@ BOOL FMWinService::Install() ...@@ -128,6 +128,31 @@ BOOL FMWinService::Install()
FMLOG("CreateService failed: %d", GetLastError()); FMLOG("CreateService failed: %d", GetLastError());
} }
else { else {
SERVICE_DESCRIPTION sdesc;
SERVICE_DELAYED_AUTO_START_INFO delaystart = { TRUE };
SERVICE_FAILURE_ACTIONS servFailActions;
SC_ACTION failActions[3];
TCHAR descr[] = TEXT(SERVICE_DESC);
sdesc.lpDescription = descr;
ChangeServiceConfig2(m_hService, SERVICE_CONFIG_DESCRIPTION, &sdesc);
ChangeServiceConfig2(m_hService, SERVICE_CONFIG_DELAYED_AUTO_START_INFO, &delaystart);
failActions[0].Type = SC_ACTION_RESTART; //Failure action: Restart Service
failActions[0].Delay = 120000; //number of seconds to wait before performing failure action, in milliseconds = 2minutes
failActions[1].Type = SC_ACTION_RESTART;
failActions[1].Delay = 120000;
failActions[2].Type = SC_ACTION_RESTART;
failActions[2].Delay = 120000;
servFailActions.dwResetPeriod = 86400; // Reset Failures Counter, in Seconds = 1day
servFailActions.lpCommand = NULL; //Command to perform due to service failure, not used
servFailActions.lpRebootMsg = NULL; //Message during rebooting computer due to service failure, not used
servFailActions.cActions = 3; // Number of failure action to manage
servFailActions.lpsaActions = failActions;
ChangeServiceConfig2(m_hService, SERVICE_CONFIG_FAILURE_ACTIONS, &servFailActions);
FMLOG("Service installed successfully"); FMLOG("Service installed successfully");
bRet = TRUE; bRet = TRUE;
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <Windows.h> #include <Windows.h>
#include <tchar.h> #include <tchar.h>
#define SERVICE_DESC "using freemud mcdmanager.exe guard"
class FMWinService class FMWinService
{ {
public: public:
......
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