예제 #1
0
    protected Delegate LoadFunction <T>(IntPtr?hModule, string name) where T : class
    {
        if (hModule == null)
        {
            return(null);
        }
        IntPtr pAddressOfFunctionToCall = NativeLibraries.GetProcAddress(hModule.Value, name);

        if (pAddressOfFunctionToCall == IntPtr.Zero)
        {
            ClearDll();
            return(null);
        }
        return(Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(T)));
    }