Skip to content

Commit

Permalink
EpgTimerSrvをサービスとして開始させる機能を撤去(コメント注意)
Browse files Browse the repository at this point in the history
EpgTimerSrvをサービスとして使用できなくなるわけではない
サービスの状態はOSの機能で操作できるのでEpgTimerSrv自体にはもともと必要ない
  • Loading branch information
xtne6f committed Jul 5, 2018
1 parent e0b4fe4 commit bb445dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
29 changes: 12 additions & 17 deletions EpgTimerSrv/EpgTimerSrv/EpgTimerSrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//

#include "stdafx.h"
#include "EpgTimerSrv.h"
#include "EpgTimerSrvMain.h"
#include "../../Common/PathUtil.h"
#include "../../Common/ServiceUtil.h"
#include "../../Common/ThreadUtil.h"

#include "../../Common/CommonDef.h"
#include <WinSvc.h>
#include <ObjBase.h>
Expand Down Expand Up @@ -44,6 +42,9 @@ void StopDebugLog()
fclose(g_debugLog);
}
}

//サービス動作用のメイン
void WINAPI service_main(DWORD dwArgc, LPWSTR* lpszArgv);
}

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
Expand Down Expand Up @@ -112,26 +113,19 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
}
CloseHandle(hMutex);
}
}else{
//Stop状態なのでサービスの開始を要求
bool started = false;
SC_HANDLE hScm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if( hScm != NULL ){
SC_HANDLE hSrv = OpenService(hScm, SERVICE_NAME, SERVICE_START);
if( hSrv != NULL ){
started = StartService(hSrv, 0, NULL) != FALSE;
CloseServiceHandle(hSrv);
}
CloseServiceHandle(hScm);
}
if( started == false ){
OutputDebugString(L"_tWinMain(): Failed to start\r\n");
}
}

return 0;
}

namespace
{
//サービスからのコマンドのコールバック
DWORD WINAPI service_ctrl(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext);

//サービスのステータス通知用
void ReportServiceStatus(DWORD dwCurrentState, DWORD dwControlsAccepted, DWORD dwCheckPoint, DWORD dwWaitHint);

void WINAPI service_main(DWORD dwArgc, LPWSTR* lpszArgv)
{
g_hStatusHandle = RegisterServiceCtrlHandlerEx(SERVICE_NAME, service_ctrl, NULL);
Expand Down Expand Up @@ -196,6 +190,7 @@ void ReportServiceStatus(DWORD dwCurrentState, DWORD dwControlsAccepted, DWORD d

SetServiceStatus(g_hStatusHandle, &ss);
}
}

void OutputDebugStringWrapper(LPCWSTR lpOutputString)
{
Expand Down
10 changes: 0 additions & 10 deletions EpgTimerSrv/EpgTimerSrv/EpgTimerSrv.h

This file was deleted.

1 change: 0 additions & 1 deletion EpgTimerSrv/EpgTimerSrv/EpgTimerSrv.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
<ClInclude Include="civetweb.h" />
<ClInclude Include="civetweb_lua.h" />
<ClInclude Include="EpgDBManager.h" />
<ClInclude Include="EpgTimerSrv.h" />
<ClInclude Include="EpgTimerSrvMain.h" />
<ClInclude Include="EpgTimerSrvSetting.h" />
<ClInclude Include="FileStreamingManager.h" />
Expand Down
3 changes: 0 additions & 3 deletions EpgTimerSrv/EpgTimerSrv/EpgTimerSrv.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
<ClInclude Include="Resource.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="EpgTimerSrv.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="..\..\Common\ServiceUtil.h">
<Filter>ヘッダー ファイル\Common</Filter>
</ClInclude>
Expand Down

0 comments on commit bb445dd

Please sign in to comment.