StoneU_HC_CARDOCX.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // StoneU_HC_CARDOCX.cpp : CStoneU_HC_CARDOCXApp 和 DLL 注册的实现。
  2. #include "stdafx.h"
  3. #include "StoneU_HC_CARDOCX.h"
  4. #include "Global.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #endif
  8. CStoneU_HC_CARDOCXApp NEAR theApp;
  9. const GUID CDECL BASED_CODE _tlid =
  10. { 0xDA935744, 0x8DBC, 0x4546, { 0xA6, 0xC2, 0x2F, 0xDE, 0x72, 0xF6, 0x4, 0x4C } };
  11. const WORD _wVerMajor = 1;
  12. const WORD _wVerMinor = 0;
  13. BOOL FolderExist(CString strPath)
  14. {
  15. WIN32_FIND_DATA wfd;
  16. BOOL rValue = FALSE;
  17. HANDLE hFind = FindFirstFile(strPath, &wfd);
  18. if( (hFind != INVALID_HANDLE_VALUE) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
  19. {
  20. rValue = TRUE;
  21. }
  22. FindClose(hFind);
  23. return rValue;
  24. }
  25. // CStoneU_HC_CARDOCXApp::InitInstance - DLL 初始化
  26. BOOL CStoneU_HC_CARDOCXApp::InitInstance()
  27. {
  28. BOOL bInit = COleControlModule::InitInstance();
  29. if (bInit)
  30. {
  31. AfxEnableControlContainer();
  32. CCommandLineInfo cmdInfo;
  33. ParseCommandLine(cmdInfo);
  34. // Standard initialization
  35. // If you are not using these features and wish to reduce the size
  36. // of your final executable, you should remove from the following
  37. // the specific initialization routines you do not need.
  38. #ifdef _AFXDLL
  39. Enable3dControls(); // Call this when using MFC in a shared DLL
  40. #else
  41. Enable3dControlsStatic(); // Call this when linking to MFC statically
  42. #endif
  43. if (!AfxSocketInit())
  44. {
  45. AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  46. return FALSE;
  47. }
  48. g_IniFile.SetPath("C:\\OCXRect.ini");
  49. g_IniFile.GetVarInt(_T("WH"),_T("W"),g_nFrameWeight);
  50. g_IniFile.GetVarInt(_T("WH"),_T("H"),g_nFrameHeight);
  51. //if( g_nFrameWeight<=750 ) g_nFrameWeight = 750;
  52. //if( g_nFrameHeight<=570 ) g_nFrameHeight = 570;
  53. g_IniFile.SetPath("C:\\videoset.ini");
  54. g_IniFile.GetVarStr(_T("video"),_T("VideoPath"),g_strVideoPath);
  55. g_IniFile.GetVarInt(_T("video"),_T("DiskVelume"),g_nDiskVolume);
  56. g_IniFile.GetVarInt(_T("video"),_T("OperateType"),g_nOperateType);
  57. g_IniFile.GetVarInt(_T("video"),_T("VideoMaxTime"),g_nVideoMaxTime);
  58. g_IniFile.GetVarInt(_T("video"),_T("NoMotionTime"),g_nNoMotionTime);
  59. //RECT
  60. g_IniFile.GetVarInt(_T("RECT"),_T("Change"),g_nChangePos);
  61. int left=0,top=0,right=0,bottom=0;
  62. g_IniFile.GetVarInt(_T("RECT"),_T("Left"),left);
  63. g_IniFile.GetVarInt(_T("RECT"),_T("Top"),top);
  64. g_IniFile.GetVarInt(_T("RECT"),_T("Right"),right);
  65. g_IniFile.GetVarInt(_T("RECT"),_T("Bottom"),bottom);
  66. g_Rect.left = left;
  67. g_Rect.top = top;
  68. g_Rect.right = right;
  69. g_Rect.bottom = bottom;
  70. if( g_Rect.right<=550 ) g_Rect.right = 550;
  71. if( g_Rect.bottom<=400 ) g_Rect.bottom = 400;
  72. if( g_strVideoPath=="" )
  73. g_strVideoPath = "D:\\StoneUVideo\\";
  74. if (!FolderExist(g_strVideoPath))
  75. CreateDirectory(g_strVideoPath, NULL);
  76. }
  77. //RegisterLogRecordCallback(LogRecordFunc, &dlg);
  78. return bInit;
  79. }
  80. // CStoneU_HC_CARDOCXApp::ExitInstance - DLL 终止
  81. int CStoneU_HC_CARDOCXApp::ExitInstance()
  82. {
  83. // TODO: 在此添加您自己的模块终止代码。
  84. return COleControlModule::ExitInstance();
  85. }
  86. // DllRegisterServer - 将项添加到系统注册表
  87. STDAPI DllRegisterServer(void)
  88. {
  89. AFX_MANAGE_STATE(_afxModuleAddrThis);
  90. if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
  91. return ResultFromScode(SELFREG_E_TYPELIB);
  92. if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
  93. return ResultFromScode(SELFREG_E_CLASS);
  94. return NOERROR;
  95. }
  96. // DllUnregisterServer - 将项从系统注册表中移除
  97. STDAPI DllUnregisterServer(void)
  98. {
  99. AFX_MANAGE_STATE(_afxModuleAddrThis);
  100. if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
  101. return ResultFromScode(SELFREG_E_TYPELIB);
  102. if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
  103. return ResultFromScode(SELFREG_E_CLASS);
  104. return NOERROR;
  105. }