예제 #1
0
        public string GetParamString(Out123.Params aParam)
        {
            long   null_value  = 0; // not interested in int value because want the string value.
            double null_fvalue = 0; // not interested in double value because want the string value.
            IntPtr strPtr      = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>());

            Out123.Errors error = Out123NativeMethods.GetParam(handle, aParam, ref null_value, ref null_fvalue, strPtr);
            if (error != Out123.Errors.OK)
            {
                throw new Out123.ErrorException(error);
            }

            IntPtr subPtr = Marshal.ReadIntPtr(strPtr);

            if (subPtr == IntPtr.Zero)
            {
                Marshal.FreeHGlobal(strPtr);
                throw new Out123.ErrorException("unknow error");
            }
            else
            {
                string result = Marshal.PtrToStringAnsi(subPtr);
                Marshal.FreeHGlobal(strPtr);
                return(result);
            }
        }
예제 #2
0
        public long GetParamInt(Out123.Params aParam)
        {
            long   result      = 0;
            double null_fValue = 0; // not interested in float value because want the int value.
            IntPtr null_sValue = IntPtr.Zero;

            Out123.Errors error = Out123NativeMethods.GetParam(handle, aParam, ref result, ref null_fValue, null_sValue);
            if (error != Out123.Errors.OK)
            {
                throw new Out123.ErrorException(error);
            }
            return(result);
        }
예제 #3
0
        public double GetParamFloat(Out123.Params aParam)
        {
            long   null_value  = 0;           // not interested in int value because want the doule value.
            double result      = 0;
            IntPtr null_sValue = IntPtr.Zero; // not interested in sValue because want the doule value.

            Out123.Errors error = Out123NativeMethods.GetParam(handle, aParam, ref null_value, ref result, null_sValue);
            if (error != Out123.Errors.OK)
            {
                throw new Out123.ErrorException(this);
            }
            return(result);
        }