/// <summary> /// /// </summary> /// <param name="fileName"></param> public DynamicNativeLibrary(string fileName) { m_libraryHandle = DynamicNativeLibraryHelper.LoadLibrary(fileName); if (m_libraryHandle.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } }
/// <summary> /// /// </summary> /// <typeparam name="TT"></typeparam> /// <param name="functionName"></param> /// <returns></returns> public TT FindUmanagedFunction <TT>(string functionName) where TT : class { var ptr = DynamicNativeLibraryHelper.GetProcAddress(m_libraryHandle, functionName); if (ptr == IntPtr.Zero) { return(null); } return(Marshal.GetDelegateForFunctionPointer(ptr, typeof(TT)) as TT); }
protected override bool ReleaseHandle() => DynamicNativeLibraryHelper.FreeLibrary(handle);