Пример #1
0
        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));
        }
Пример #2
0
 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());
     }
 }
Пример #3
0
 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
         {
         }
     }
 }
Пример #4
0
 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
         {
         }
     }
 }
Пример #5
0
 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());
     }
 }