/// <summary> /// 加载动态库 /// </summary> /// <param name="_strFilePath">动态库的完整路径</param> /// <returns>成功返回 true 失败返回 false</returns> public static bool LoadHikVideoAPI(string _strFilePath) { if (m_hHikVedeo != 0) { return(true); } if (File.Exists(_strFilePath) != true) { return(false); } m_hHikVedeo = Win32API.LoadLibrary(_strFilePath); if (m_hHikVedeo <= 0) { return(false); } #region 实例化委托并判null NET_HIK_Login_V40 = (NET_DVR_Login_V40)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_Login_V40", typeof(NET_DVR_Login_V40)); if (NET_HIK_Login_V40 == null) { return(false); } NET_HIK_Init = (NET_DVR_Init)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_Init", typeof(NET_DVR_Init)); if (NET_HIK_Init == null) { return(false); } NET_HIK_Cleanup = (NET_DVR_Cleanup)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_Cleanup", typeof(NET_DVR_Cleanup)); if (NET_HIK_Cleanup == null) { return(false); } NET_HIK_GetLastError = (NET_DVR_GetLastError)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_GetLastError", typeof(NET_DVR_GetLastError)); if (NET_HIK_GetLastError == null) { return(false); } NET_HIK_RealPlay_V40 = (NET_DVR_RealPlay_V40)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_RealPlay_V40", typeof(NET_DVR_RealPlay_V40)); if (NET_HIK_RealPlay_V40 == null) { return(false); } NET_HIK_StopRealPlay = (NET_DVR_StopRealPlay)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_StopRealPlay", typeof(NET_DVR_StopRealPlay)); if (NET_HIK_StopRealPlay == null) { return(false); } NET_HIK_Logout_V30 = (NET_DVR_Logout_V30)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_Logout_V30", typeof(NET_DVR_Logout_V30)); //if (NET_HIK_Logout_V30 == null) { return false; } //NET_HIK_SetDVRMessageCallBack_V31 = (NET_DVR_SetDVRMessageCallBack_V31)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_SetDVRMessageCallBack_V31", // typeof(NET_DVR_SetDVRMessageCallBack_V31)); //if (NET_HIK_SetDVRMessageCallBack_V31 == null) { return false; } NET_HIK_StartRemoteConfig = (NET_DVR_StartRemoteConfig)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_StartRemoteConfig", typeof(NET_DVR_StartRemoteConfig)); if (NET_HIK_StartRemoteConfig == null) { return(false); } NET_HIK_StopRemoteConfig = (NET_DVR_StopRemoteConfig)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_StopRemoteConfig", typeof(NET_DVR_StopRemoteConfig)); if (NET_HIK_StopRemoteConfig == null) { return(false); } NET_HIK_SetExceptionCallBack_V30 = (NET_DVR_SetExceptionCallBack_V30)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_SetExceptionCallBack_V30", typeof(NET_DVR_SetExceptionCallBack_V30)); if (NET_HIK_SetExceptionCallBack_V30 == null) { return(false); } NET_HIK_SetupAlarmChan_V30 = (NET_DVR_SetupAlarmChan_V30)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_SetupAlarmChan_V30", typeof(NET_DVR_SetupAlarmChan_V30)); if (NET_HIK_SetupAlarmChan_V30 == null) { return(false); } NET_HIK_SetupAlarmChan_V41 = (NET_DVR_SetupAlarmChan_V41)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_SetupAlarmChan_V41", typeof(NET_DVR_SetupAlarmChan_V41)); if (NET_HIK_SetupAlarmChan_V41 == null) { return(false); } //NET_HIK_StartListen_V30 = (NET_DVR_StartListen_V30)FuncCommon.GetFunctionAddress(m_hHikVedeo, "NET_DVR_StartListen_V30", // typeof(NET_DVR_StartListen_V30)); //if (NET_HIK_StartListen_V30 == null) { return false; } #endregion return(true); }
public int InitCamera(IntPtr dvrHandle) { string logPath = Path.Combine(Application.StartupPath, "peripheral", "aoto", "FaceCamLib", "SdkLog"); string dllPath = Path.Combine(Application.StartupPath, "peripheral", "aoto", "FaceCamLib", "HCNetSDK.dll"); intPtr = Win32ApiInvoker.LoadLibrary(dllPath); IntPtr api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_Init"); init = (NET_DVR_Init)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_Init)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_Login_V30"); login = (NET_DVR_Login_V30)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_Login_V30)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_GetLastError"); lastError = (NET_DVR_GetLastError)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_GetLastError)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_SetLogToFile"); setLog = (NET_DVR_SetLogToFile)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_SetLogToFile)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_RealPlay_V40"); realPlay = (NET_DVR_RealPlay_V40)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_RealPlay_V40)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_StopRealPlay"); stopPlay = (NET_DVR_StopRealPlay)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_StopRealPlay)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_CapturePicture"); capturePicture = (NET_DVR_CapturePicture)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_CapturePicture)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_MakeKeyFrame"); makeKeyFrame = (NET_DVR_MakeKeyFrame)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_MakeKeyFrame)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_SaveRealData"); saveReallData = (NET_DVR_SaveRealData)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_SaveRealData)); api = Win32ApiInvoker.GetProcAddress(intPtr, "NET_DVR_StopSaveRealData"); stopRealData = (NET_DVR_StopSaveRealData)Marshal.GetDelegateForFunctionPointer(api, typeof(NET_DVR_StopSaveRealData)); //初始化SDK m_bInitSDK = init(); if (m_bInitSDK == false) { //MessageBox.Show("NET_DVR_Init error!"); } else { //初始化日志 setLog(3, logPath, true); } //初始化摄像机 if (m_UserID < 0) { m_UserID = login(dvrIPAddress2, dvrPortNumber, dvrUserName, dvrPassword, ref deviceInfo); iLastErr = lastError(); if (m_UserID == 0) { dvrPtr = dvrHandle; } } else { } return(m_UserID); }