StoneU_HC_OCX.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // StoneU_HC_OCX.cpp : CStoneU_HC_OCXApp 和 DLL 注册的实现。
  2. #include "stdafx.h"
  3. #include "StoneU_HC_OCX.h"
  4. #include "Global.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #endif
  8. CStoneU_HC_OCXApp NEAR theApp;
  9. const GUID CDECL BASED_CODE _tlid =
  10. { 0x5931E57C, 0xE65F, 0x49F7, { 0x8E, 0x9E, 0x87, 0x8, 0x77, 0xA8, 0xA8, 0xA1 } };
  11. const WORD _wVerMajor = 1;
  12. const WORD _wVerMinor = 0;
  13. // CStoneU_HC_OCXApp::InitInstance - DLL 初始化
  14. BOOL CStoneU_HC_OCXApp::InitInstance()
  15. {
  16. BOOL bInit = COleControlModule::InitInstance();
  17. if (bInit)
  18. {
  19. AfxEnableControlContainer();
  20. // Standard initialization
  21. // If you are not using these features and wish to reduce the size
  22. // of your final executable, you should remove from the following
  23. // the specific initialization routines you do not need.
  24. #ifdef _AFXDLL
  25. Enable3dControls(); // Call this when using MFC in a shared DLL
  26. #else
  27. Enable3dControlsStatic(); // Call this when linking to MFC statically
  28. #endif
  29. NET_DVR_Init();
  30. int isupport = NET_DVR_IsSupport();
  31. //if (!(isupport & NET_DVR_SUPPORT_DDRAW))
  32. //{
  33. // AfxMessageBox("显卡无法支持!");
  34. // //::MessageBox("显卡无法支持!", "温馨提示", MB_ICONINFORMATION);
  35. // return FALSE;
  36. //}
  37. //if (!(isupport & NET_DVR_SUPPORT_SSE))
  38. //{
  39. // AfxMessageBox("硬件无法支持,需要PIII及PIII以上CPU!");
  40. // //MessageBox("硬件无法支持,需要PIII及PIII以上CPU!", "温馨提示", MB_ICONINFORMATION);
  41. // return FALSE;
  42. //}
  43. //if (!(isupport & NET_DVR_SUPPORT_BLT))
  44. //{
  45. // AfxMessageBox("显卡无法支持!");
  46. // //MessageBox("显卡无法支持!", "温馨提示", MB_ICONINFORMATION);
  47. // return FALSE;
  48. //}
  49. if(!F_GetSystemInfo())
  50. {
  51. AfxMessageBox("获取系统信息错误!");
  52. //MessageBox("获取系统信息错误!", "温馨提示", MB_ICONINFORMATION);
  53. }
  54. g_IniFile.SetPath("C:\\OCXRect.ini");
  55. g_IniFile.GetVarInt(_T("WH"),_T("W"),g_nFrameWeight);
  56. g_IniFile.GetVarInt(_T("WH"),_T("H"),g_nFrameHeight);
  57. if( g_nFrameWeight<=750 ) g_nFrameWeight = 750;
  58. if( g_nFrameHeight<=570 ) g_nFrameHeight = 570;
  59. g_IniFile.SetPath("C:\\videoDvsset.ini");
  60. //g_IniFile.GetVarStr(_T("video"),_T("VideoPath"),g_strVideoPath);
  61. //g_IniFile.GetVarInt(_T("video"),_T("DiskVelume"),g_nDiskVolume);
  62. //g_IniFile.GetVarInt(_T("video"),_T("OperateType"),g_nOperateType);
  63. g_IniFile.GetVarInt(_T("video"),_T("VideoMaxTime"),g_nVideoMaxTime);
  64. g_IniFile.GetVarInt(_T("video"),_T("NoMotionTime"),g_nNoMotionTime);
  65. }
  66. return bInit;
  67. }
  68. // CStoneU_HC_OCXApp::ExitInstance - DLL 终止
  69. int CStoneU_HC_OCXApp::ExitInstance()
  70. {
  71. // TODO: 在此添加您自己的模块终止代码。
  72. NET_DVR_Cleanup();
  73. return COleControlModule::ExitInstance();
  74. }
  75. BOOL CStoneU_HC_OCXApp::F_GetSystemInfo()
  76. {
  77. DWORD dw=GetLogicalDriveStrings(0,NULL);
  78. LPTSTR pAllDrivers=new char[dw];
  79. ::GetLogicalDriveStrings(dw,pAllDrivers);
  80. LPTSTR pDriver=pAllDrivers;
  81. char tempDriver[26];
  82. DWORD DriverNum=0;
  83. while(pDriver[0]!=0)
  84. {
  85. tempDriver[DriverNum++]=*pDriver;
  86. pDriver=_tcschr(pDriver,0)+1; //定位到下一个盘符
  87. }
  88. //volume information
  89. TCHAR lpVolumeNameBuffer[200];
  90. DWORD dwVolumeSerialNumber,dwMaxComLength;
  91. DWORD dwFileSystemFlags;
  92. TCHAR lpFileSystemNameBuffer[50];
  93. DWORD HardNum=0;
  94. for(DWORD num=0;num<DriverNum;num++)
  95. {
  96. CString csRootPath;
  97. csRootPath.Format("%c%s",tempDriver[num],":\\");
  98. if(GetDriveType(csRootPath)==DRIVE_FIXED)
  99. {
  100. if(GetVolumeInformation(csRootPath,lpVolumeNameBuffer,sizeof(lpVolumeNameBuffer),&dwVolumeSerialNumber,
  101. &dwMaxComLength,&dwFileSystemFlags,lpFileSystemNameBuffer,sizeof(lpFileSystemNameBuffer)))
  102. {
  103. this->m_cHardDriver[HardNum++]=tempDriver[num];
  104. }
  105. }
  106. }
  107. m_iDriverNum=HardNum;
  108. delete[] pAllDrivers;
  109. return TRUE;
  110. }
  111. // DllRegisterServer - 将项添加到系统注册表
  112. STDAPI DllRegisterServer(void)
  113. {
  114. AFX_MANAGE_STATE(_afxModuleAddrThis);
  115. if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
  116. return ResultFromScode(SELFREG_E_TYPELIB);
  117. if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
  118. return ResultFromScode(SELFREG_E_CLASS);
  119. return NOERROR;
  120. }
  121. // DllUnregisterServer - 将项从系统注册表中移除
  122. STDAPI DllUnregisterServer(void)
  123. {
  124. AFX_MANAGE_STATE(_afxModuleAddrThis);
  125. if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
  126. return ResultFromScode(SELFREG_E_TYPELIB);
  127. if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
  128. return ResultFromScode(SELFREG_E_CLASS);
  129. return NOERROR;
  130. }