VmsControl.cpp 3.4 KB

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