TimeSyncServer.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // TimeSyncServer.h : PROJECT_NAME 应用程序的主头文件
  2. //
  3. #pragma once
  4. #ifndef __AFXWIN_H__
  5. #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
  6. #endif
  7. #include "resource.h" // 主符号
  8. #include <WinSvc.h>
  9. #include <DbgHelp.h>
  10. #pragma comment(lib, "dbghelp.lib")
  11. extern SERVICE_STATUS m_ServiceStatus;
  12. extern SERVICE_STATUS_HANDLE m_ServiceStatusHandle;
  13. //函数声明
  14. void WINAPI ServiceMain(DWORD argc, LPTSTR *argv);
  15. void WINAPI ServiceCtrlHandler(DWORD Opcode);
  16. BOOL InstallService(CString &strPath);
  17. BOOL DeleteService();
  18. class CDumpCatch
  19. {
  20. public:
  21. CDumpCatch();
  22. ~CDumpCatch();
  23. private:
  24. static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI TempSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
  25. static BOOL ReleaseDumpFile(const std::string& strPath, EXCEPTION_POINTERS* pException);
  26. static LONG WINAPI UnhandledExceptionFilterEx(struct _EXCEPTION_POINTERS* pException);
  27. static void MyPureCallHandler(void);
  28. static void MyInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved);
  29. BOOL AddExceptionHandle();
  30. BOOL RemoveExceptionHandle();
  31. BOOL PreventSetUnhandledExceptionFilter();
  32. void SetInvalidHandle();
  33. void UnSetInvalidHandle();
  34. private:
  35. LPTOP_LEVEL_EXCEPTION_FILTER m_preFilter;
  36. _invalid_parameter_handler m_preIph;
  37. _purecall_handler m_prePch;
  38. };
  39. // CTimeSyncServerApp:
  40. // 有关此类的实现,请参阅 TimeSyncServer.cpp
  41. //
  42. class CTimeSyncServerApp : public CWinApp
  43. {
  44. public:
  45. CTimeSyncServerApp();
  46. // 重写
  47. public:
  48. virtual BOOL InitInstance();
  49. static void StartTheAppServices(WORD);
  50. // 实现
  51. DECLARE_MESSAGE_MAP()
  52. };
  53. extern CTimeSyncServerApp theApp;