// StoneU_HC_OCX.cpp : CStoneU_HC_OCXApp 和 DLL 注册的实现。 #include "stdafx.h" #include "StoneU_HC_OCX.h" #include "Global.h" #ifdef _DEBUG #define new DEBUG_NEW #endif CStoneU_HC_OCXApp NEAR theApp; const GUID CDECL BASED_CODE _tlid = { 0x5931E57C, 0xE65F, 0x49F7, { 0x8E, 0x9E, 0x87, 0x8, 0x77, 0xA8, 0xA8, 0xA1 } }; const WORD _wVerMajor = 1; const WORD _wVerMinor = 0; // CStoneU_HC_OCXApp::InitInstance - DLL 初始化 BOOL CStoneU_HC_OCXApp::InitInstance() { BOOL bInit = COleControlModule::InitInstance(); if (bInit) { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif NET_DVR_Init(); int isupport = NET_DVR_IsSupport(); //if (!(isupport & NET_DVR_SUPPORT_DDRAW)) //{ // AfxMessageBox("显卡无法支持!"); // //::MessageBox("显卡无法支持!", "温馨提示", MB_ICONINFORMATION); // return FALSE; //} //if (!(isupport & NET_DVR_SUPPORT_SSE)) //{ // AfxMessageBox("硬件无法支持,需要PIII及PIII以上CPU!"); // //MessageBox("硬件无法支持,需要PIII及PIII以上CPU!", "温馨提示", MB_ICONINFORMATION); // return FALSE; //} //if (!(isupport & NET_DVR_SUPPORT_BLT)) //{ // AfxMessageBox("显卡无法支持!"); // //MessageBox("显卡无法支持!", "温馨提示", MB_ICONINFORMATION); // return FALSE; //} if(!F_GetSystemInfo()) { AfxMessageBox("获取系统信息错误!"); //MessageBox("获取系统信息错误!", "温馨提示", MB_ICONINFORMATION); } g_IniFile.SetPath("C:\\OCXRect.ini"); g_IniFile.GetVarInt(_T("WH"),_T("W"),g_nFrameWeight); g_IniFile.GetVarInt(_T("WH"),_T("H"),g_nFrameHeight); if( g_nFrameWeight<=750 ) g_nFrameWeight = 750; if( g_nFrameHeight<=570 ) g_nFrameHeight = 570; g_IniFile.SetPath("C:\\videoDvsset.ini"); //g_IniFile.GetVarStr(_T("video"),_T("VideoPath"),g_strVideoPath); //g_IniFile.GetVarInt(_T("video"),_T("DiskVelume"),g_nDiskVolume); //g_IniFile.GetVarInt(_T("video"),_T("OperateType"),g_nOperateType); g_IniFile.GetVarInt(_T("video"),_T("VideoMaxTime"),g_nVideoMaxTime); g_IniFile.GetVarInt(_T("video"),_T("NoMotionTime"),g_nNoMotionTime); } return bInit; } // CStoneU_HC_OCXApp::ExitInstance - DLL 终止 int CStoneU_HC_OCXApp::ExitInstance() { // TODO: 在此添加您自己的模块终止代码。 NET_DVR_Cleanup(); return COleControlModule::ExitInstance(); } BOOL CStoneU_HC_OCXApp::F_GetSystemInfo() { DWORD dw=GetLogicalDriveStrings(0,NULL); LPTSTR pAllDrivers=new char[dw]; ::GetLogicalDriveStrings(dw,pAllDrivers); LPTSTR pDriver=pAllDrivers; char tempDriver[26]; DWORD DriverNum=0; while(pDriver[0]!=0) { tempDriver[DriverNum++]=*pDriver; pDriver=_tcschr(pDriver,0)+1; //定位到下一个盘符 } //volume information TCHAR lpVolumeNameBuffer[200]; DWORD dwVolumeSerialNumber,dwMaxComLength; DWORD dwFileSystemFlags; TCHAR lpFileSystemNameBuffer[50]; DWORD HardNum=0; for(DWORD num=0;numm_cHardDriver[HardNum++]=tempDriver[num]; } } } m_iDriverNum=HardNum; delete[] pAllDrivers; return TRUE; } // DllRegisterServer - 将项添加到系统注册表 STDAPI DllRegisterServer(void) { AFX_MANAGE_STATE(_afxModuleAddrThis); if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) return ResultFromScode(SELFREG_E_CLASS); return NOERROR; } // DllUnregisterServer - 将项从系统注册表中移除 STDAPI DllUnregisterServer(void) { AFX_MANAGE_STATE(_afxModuleAddrThis); if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) return ResultFromScode(SELFREG_E_CLASS); return NOERROR; }