Exemple #1
0
        public static int IMOS_XP_OpenInputStream(int port, byte[] header, uint bufPoolSize = 2 * 1024 * 1024)
        {
            int    size = 0;
            IntPtr ptr  = IntPtr.Zero;

            if (header != null)
            {
                size = header.Length;
                ptr  = Marshal.AllocHGlobal(size);
                Marshal.Copy(header, 0, ptr, size);
            }

            int ret = 0;

            if (_isX64)
            {
                ret = Native64.IMOS_XP_OpenInputStream((uint)port, ptr, (uint)size, bufPoolSize);
            }
            else
            {
                ret = Native32.IMOS_XP_OpenInputStream((uint)port, ptr, (uint)size, bufPoolSize);
            }

            if (ptr != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(ptr);
            }

            return(ret);
        }