/// <summary> /// 指定名のアンマネージ関数ポインタをデリゲートに変換 /// </summary> /// <param name="szProcName">アンマネージ関数名</param> /// <param name="typDelegate">変換するデリゲートのType</param> /// <returns>変換したデリゲート</returns> public Delegate GetDelegate(string szProcName, Type typDelegate) { IntPtr pProc = BindDLL.GetProcAddress(_pModule, szProcName); if (pProc != IntPtr.Zero) { Delegate oDG = Marshal.GetDelegateForFunctionPointer(pProc, typDelegate); return(oDG); } int nResult = Marshal.GetHRForLastWin32Error(); throw Marshal.GetExceptionForHR(nResult); }