public static IntPtr GetProcAddress(IntPtr hModule, string functionName) { IntPtr procAddress = NativeMethods.GetProcAddress(hModule, functionName); if (procAddress == IntPtr.Zero) { string moduleFileName = LibraryMethods.GetModuleFileName(hModule); throw new Exception(moduleFileName); } return(procAddress); }
public static T GetFunction <T>(IntPtr hModule, string functionName) where T : Delegate { return((T)Marshal.GetDelegateForFunctionPointer(LibraryMethods.GetProcAddress(hModule, functionName), typeof(T))); }