Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 public void SetParamFloat(Out123.Params aParam, double value)
 {
     Out123.Errors error = Out123NativeMethods.Param(handle, aParam, IntPtr.Zero, value, IntPtr.Zero);
     if (error != Out123.Errors.OK)
     {
         throw new Out123.ErrorException(error);
     }
 }
Ejemplo n.º 3
0
 public void SetParamInt(Out123.Params aParam, long value)
 {
     Out123.Errors error = Out123NativeMethods.Param(handle, aParam, new IntPtr(value), 0, IntPtr.Zero);
     if (error != Out123.Errors.OK)
     {
         throw new Out123.ErrorException(error);
     }
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public void SetParamString(Out123.Params aParam, string value)
        {
            IntPtr sValuePtr = IntPtr.Zero;

            if (sValuePtr != null)
            {
                sValuePtr = Marshal.StringToHGlobalAnsi(value);
            }
            Out123.Errors result = Out123NativeMethods.Param(handle, aParam, IntPtr.Zero, 0, sValuePtr);
            if (sValuePtr != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(sValuePtr);
            }
        }
Ejemplo n.º 7
0
 internal extern static Out123.Errors GetParam(IntPtr handle, [MarshalAs(UnmanagedType.I4)] Out123.Params code, ref long value, ref double fvalue, IntPtr svalue);