예제 #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());
     }
 }