public unsafe static int TryExcelImpl(int xlFunction, out object result, params object[] parameters) { if (XlAddIn.XlCallVersion < 12) { return(TryExcelImpl4(xlFunction, out result, parameters)); } // Else Excel 12+ if (Excel12v == null) { try { IntPtr hModuleProcess = GetModuleHandle(null); IntPtr pfnExcel12v = GetProcAddress(hModuleProcess, "MdCallBack12"); Excel12v = (Excel12vDelegate)Marshal.GetDelegateForFunctionPointer(pfnExcel12v, typeof(Excel12vDelegate)); } catch { } if (Excel12v == null) { result = null; return(32); /*XlCall.XlReturn.XlReturnFailed*/ } } return(TryExcelImpl12(xlFunction, out result, parameters)); }
internal unsafe static void SetExcel12EntryPt(IntPtr pfnExcel12v) { Debug.Print("SetExcel12EntryPt called."); FetchExcel12EntryPt(); if (Excel12v == null && pfnExcel12v != null) { Debug.Print("SetExcel12EntryPt - setting delegate."); Excel12v = (Excel12vDelegate)Marshal.GetDelegateForFunctionPointer(pfnExcel12v, typeof(Excel12vDelegate)); Debug.Print("SetExcel12EntryPt - setting delegate OK? - " + (Excel12v != null).ToString()); } }
private unsafe static void FetchExcel12EntryPt() { if (Excel12v == null) { try { IntPtr hModuleProcess = GetModuleHandle(null); IntPtr pfnExcel12v = GetProcAddress(hModuleProcess, "MdCallBack12"); if (pfnExcel12v != IntPtr.Zero) { Excel12v = (Excel12vDelegate)Marshal.GetDelegateForFunctionPointer(pfnExcel12v, typeof(Excel12vDelegate)); } } catch { } } }
private static unsafe void FetchExcel12EntryPt() { if (Excel12v == null) { try { IntPtr hModuleProcess = GetModuleHandle(null); IntPtr pfnExcel12v = GetProcAddress(hModuleProcess, "MdCallBack12"); if (pfnExcel12v != IntPtr.Zero) { Excel12v = (Excel12vDelegate)Marshal.GetDelegateForFunctionPointer(pfnExcel12v, typeof(Excel12vDelegate)); } } catch { } } }
internal static unsafe void SetExcel12EntryPt(IntPtr pfnExcel12v) { Debug.Print("SetExcel12EntryPt called."); FetchExcel12EntryPt(); if (Excel12v == null && pfnExcel12v != null) { Debug.Print("SetExcel12EntryPt - setting delegate."); Excel12v = (Excel12vDelegate)Marshal.GetDelegateForFunctionPointer(pfnExcel12v, typeof(Excel12vDelegate)); Debug.Print("SetExcel12EntryPt - setting delegate OK? - " + (Excel12v != null).ToString()); } }