Beispiel #1
0
        private unsafe static int TryExcelImpl12(int xlFunction, out object result, params object[] parameters)
        {
            int xlReturn;

            // Set up the memory to hold the result from the call
            XlOper12 resultOper = new XlOper12();

            resultOper.xlType = XlType12.XlTypeEmpty;
            XlOper12 *pResultOper = &resultOper;  // No need to pin for local struct

            // Special kind of ObjectArrayMarshaler for the parameters (rank 1)
            using (XlMarshalXlOperArrayContext paramMarshaler
                       = new XlMarshalXlOperArrayContext(1, true))
            {
                XlOper12 **ppOperParameters = (XlOper12 **)paramMarshaler.ObjectArrayReturn(parameters);
                xlReturn = Excel12v(xlFunction, parameters.Length, ppOperParameters, pResultOper);
            }

            // pResultOper now holds the result of the evaluated function
            // Get ObjectMarshaler for the return value
            result = XlMarshalContext.ObjectParam((IntPtr)pResultOper);

            // And free any memory allocated by Excel
            Excel12v(xlFree, 1, &pResultOper, (XlOper12 *)IntPtr.Zero);

            return(xlReturn);
        }
Beispiel #2
0
        internal static IntPtr RegistrationInfo(IntPtr pParam)
        {
            if (!_initialized)
            {
                return(IntPtr.Zero);
            }

            object param   = XlMarshalContext.ObjectParam(pParam);
            object regInfo = XlRegistration.GetRegistrationInfo(param);

            if (regInfo == null)
            {
                return(IntPtr.Zero); // Converted to #NUM
            }

            var ctx = XlDirectMarshal.GetMarshalContext();

            return(ctx.ObjectReturn(regInfo));
        }