Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.8 KiB

  1. // C4290: C++ Exception Specification ignored
  2. #pragma warning(disable:4290)
  3. // warning C4511: 'CVssCOMApplication' : copy constructor could not be generated
  4. #pragma warning(disable:4511)
  5. // warning C4127: conditional expression is constant
  6. #pragma warning(disable:4127)
  7. /////////////////////////////////////////////////////////////////////////////
  8. // Includes
  9. #include <wtypes.h>
  10. #include <stddef.h>
  11. #include <oleauto.h>
  12. #include <stdio.h>
  13. #include "vss.h"
  14. #include "vswriter.h"
  15. #include "sqlsnap.h"
  16. #include "sqlwriter.h"
  17. DWORD g_dwMainThreadId;
  18. /////////////////////////////////////////////////////////////////////////////
  19. // Control-C handler routine
  20. BOOL WINAPI CtrlC_HandlerRoutine(
  21. IN DWORD /* dwType */
  22. )
  23. {
  24. // End the message loop
  25. if (g_dwMainThreadId != 0)
  26. PostThreadMessage(g_dwMainThreadId, WM_QUIT, 0, 0);
  27. // Mark that the break was handled.
  28. return TRUE;
  29. }
  30. CVssSqlWriterWrapper g_Wrapper;
  31. extern "C" int __cdecl wmain(HINSTANCE /*hInstance*/,
  32. HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int /*nShowCmd*/)
  33. {
  34. int nRet = 0;
  35. try
  36. {
  37. // Preparing the CTRL-C handling routine - only for testing...
  38. g_dwMainThreadId = GetCurrentThreadId();
  39. ::SetConsoleCtrlHandler(CtrlC_HandlerRoutine, TRUE);
  40. // Initialize COM library
  41. HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  42. if (FAILED(hr))
  43. throw hr;
  44. // Declare a CVssTSubWriter instance
  45. hr = g_Wrapper.CreateSqlWriter();
  46. if (FAILED(hr))
  47. throw hr;
  48. // message loop - need for STA server
  49. MSG msg;
  50. while (GetMessage(&msg, 0, 0, 0))
  51. DispatchMessage(&msg);
  52. // Subscribe the object.
  53. g_Wrapper.DestroySqlWriter();
  54. // Uninitialize COM library
  55. CoUninitialize();
  56. }
  57. catch(...)
  58. {
  59. }
  60. return nRet;
  61. }