VmsCmraViewer.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <tchar.h>
  5. //---------------------------------------------------------------------------
  6. #include "AppGlobalF.h"
  7. //---------------------------------------------------------------------------
  8. USEFORM("MAIN\FrmCameraPlayerF.cpp", FrmCameraPlayer);
  9. USEFORM("MAIN\FrmCameraScreenF.cpp", FrmCameraScreen);
  10. USEFORM("MAIN\FrmVmsCamViewerF.cpp", FrmVmsCamViewer);
  11. USEFORM("MAIN\FRAME\FRAME_ObjListF.cpp", FRAMEObjList); /* TFrame: File Type */
  12. USEFORM("MAIN\FrmCameraScreenManagerF.cpp", FrmCameraScreenManager);
  13. USEFORM("MAIN\FrmInitializeF.cpp", FrmInitialize);
  14. USEFORM("MAIN\FrmCameraFullScreenF.cpp", FrmCameraFullScreen);
  15. USEFORM("MAIN\FrmCameraInfoF.cpp", FrmCameraInfo);
  16. //---------------------------------------------------------------------------
  17. WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
  18. {
  19. int nLoginRes;
  20. DateSeparator = '-';
  21. TimeSeparator = ':';
  22. ShortDateFormat ="yyyy-MM-dd";
  23. ShortTimeFormat = "hh:nn:ss";
  24. LongTimeFormat = "hh:nn:ss";
  25. int nRes;
  26. g_nPid = (int)GetCurrentProcessId();
  27. g_sAppDir = ExtractFilePath(Application->ExeName);
  28. g_sAppName = ChangeFileExt(ExtractFileName(Application->ExeName), "");
  29. g_sCfgDir = g_sAppDir + "Cfg\\";
  30. g_sLogDir = g_sAppDir + "Log\\";
  31. ForceDirectories(g_sCfgDir.c_str());
  32. ForceDirectories(g_sLogDir.c_str());
  33. String sTempDir = g_sAppDir + "Image\\";
  34. ForceDirectories(sTempDir.c_str());
  35. String sAppDir = ExtractFilePath(Application->ExeName);
  36. ChDir(sAppDir);
  37. /*
  38. * 시스템 운영환경을 ini 파일에서 읽어 온다.
  39. */
  40. LoadDefaultConfigInfo("WEB_APP");
  41. ITSLog = new TITSLog(g_sLogDir, g_sAppName, g_AppCfg.sLogDay);
  42. ITSLog->FLogCfg = g_LogCfg;
  43. HANDLE hMutex;
  44. try
  45. {
  46. String sLockFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".lock");
  47. String sProgMutexNm = "HANTE_" + sLockFile;
  48. if ((hMutex=OpenMutex(MUTEX_ALL_ACCESS, false, sProgMutexNm.c_str()))==NULL)
  49. hMutex = CreateMutex(NULL, true, sProgMutexNm.c_str());
  50. else
  51. {
  52. LOGINFO("Program exit.... Program already running....");
  53. ActiveProgram();
  54. return 0;
  55. }
  56. }
  57. catch (Exception &exception)
  58. {
  59. LOGINFO("Program exit.... Exception Error....");
  60. Application->ShowException(&exception);
  61. return 0;
  62. }
  63. int nArgs = ParamCount();
  64. if (nArgs == 1) {
  65. if (!CheckParamRandKey(ParamStr(1))) {
  66. LOGINFO("Program exit.... Param Value Error....");
  67. goto prog_exit;
  68. }
  69. }
  70. else {
  71. LOGINFO("Program exit.... Param Count Error....");
  72. Application->MessageBox(L"\r\nVMS 영상 모니터링 프로그램을 실행 할 수 없습니다.\r\n권한이 없습니다.\r\n",
  73. L"프로그램 실행 권한 오류!!!",
  74. MB_OK|MB_ICONERROR);
  75. goto prog_exit;
  76. }
  77. try
  78. {
  79. ReportMemoryLeaksOnShutdown = true;
  80. Application->Initialize();
  81. Application->MainFormOnTaskBar = true;
  82. Application->Title = g_AppCfg.sTitle;
  83. Application->Title = "VMS 영상 모니터링";
  84. Application->CreateForm(__classid(TFrmVmsCamViewer), &FrmVmsCamViewer);
  85. Application->Run();
  86. }
  87. catch (Exception &exception)
  88. {
  89. Application->ShowException(&exception);
  90. }
  91. catch (...)
  92. {
  93. try
  94. {
  95. throw Exception("");
  96. }
  97. catch (Exception &exception)
  98. {
  99. Application->ShowException(&exception);
  100. }
  101. }
  102. prog_exit:
  103. try
  104. {
  105. ReleaseMutex(hMutex);
  106. CloseHandle(hMutex);
  107. hMutex = NULL;
  108. LOGINFO("Program end....");
  109. }
  110. catch(...)
  111. {
  112. }
  113. return 0;
  114. }
  115. //---------------------------------------------------------------------------