예제 #1
0
        public static unsafe String ReadString(IPropertyContainer propertyContainer, UInt32 key)
        {
            IntPtr size;
            String s;

            size = propertyContainer.GetPropertySize(key);
            var stringData = new Byte[size.ToInt64()];

            fixed(Byte *pStringData = stringData)
            {
                propertyContainer.ReadProperty(key, size, pStringData);
            }

            s = Encoding.UTF8.GetString(stringData);
            var nullIndex = s.IndexOf('\0');

            if (nullIndex >= 0)
            {
                return(s.Substring(0, nullIndex));
            }
            else
            {
                return(s);
            }
        }
예제 #2
0
        unsafe public static byte[] ReadBytes(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size;

            size = propertyContainer.GetPropertySize(key);
            byte[] data = new byte[size.ToInt64()];
            fixed(byte *pData = data)
            {
                propertyContainer.ReadProperty(key, size, pData);
            }

            return(data);
        }
예제 #3
0
        public static unsafe Byte[] ReadBytes(IPropertyContainer propertyContainer, UInt32 key)
        {
            IntPtr size;

            size = propertyContainer.GetPropertySize(key);
            var data = new Byte[size.ToInt64()];

            fixed(Byte *pData = data)
            {
                propertyContainer.ReadProperty(key, size, pData);
            }

            return(data);
        }
예제 #4
0
        public static unsafe IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, UInt32 key)
        {
            var size        = propertyContainer.GetPropertySize(key);
            var numElements = (Int64)size / sizeof(IntPtr);
            var ptrs        = new IntPtr[numElements];
            var data        = InteropTools.ReadBytes(propertyContainer, key);

            fixed(Byte *pData = data)
            {
                var pBS = (void **)pData;

                for (var i = 0; i < numElements; i++)
                {
                    ptrs[i] = new IntPtr(pBS[i]);
                }
            }

            return(ptrs);
        }
예제 #5
0
        unsafe public static IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size        = propertyContainer.GetPropertySize(key);
            long   numElements = (long)size / sizeof(IntPtr);

            IntPtr[] ptrs = new IntPtr[numElements];
            byte[]   data = InteropTools.ReadBytes(propertyContainer, key);

            fixed(byte *pData = data)
            {
                void **pBS = (void **)pData;

                for (int i = 0; i < numElements; i++)
                {
                    ptrs[i] = new IntPtr(pBS[i]);
                }
            }

            return(ptrs);
        }
예제 #6
0
        unsafe public static ulong[] ReadULongArray(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size        = propertyContainer.GetPropertySize(key);
            long   numElements = (long)size / sizeof(ulong);

            ulong[] ulongs = new ulong[numElements];
            byte[]  data   = InteropTools.ReadBytes(propertyContainer, key);

            fixed(byte *pData = data)
            {
                ulong *pBS = (ulong *)pData;

                for (int i = 0; i < numElements; i++)
                {
                    ulongs[i] = pBS[i];
                }
            }

            return(ulongs);
        }
예제 #7
0
        unsafe public static string ReadString(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size;
            string s;

            size = propertyContainer.GetPropertySize((uint)key);
            byte[] stringData = new byte[size.ToInt64()];
            fixed(byte *pStringData = stringData)
            {
                propertyContainer.ReadProperty((uint)key, size, pStringData);
            }

            s = Encoding.UTF8.GetString(stringData);
            int nullIndex = s.IndexOf('\0');

            if (nullIndex >= 0)
            {
                return(s.Substring(0, nullIndex));
            }
            else
            {
                return(s);
            }
        }
예제 #8
0
        public static unsafe string ReadString(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size;
            string s;

            size = propertyContainer.GetPropertySize((uint)key);
            byte[] stringData = new byte[size.ToInt64()];
            fixed (byte* pStringData = stringData)
            {
                propertyContainer.ReadProperty((uint)key, size, pStringData);
            }

            s = Encoding.UTF8.GetString(stringData);
            int nullIndex = s.IndexOf('\0');
            if (nullIndex >= 0)
                return s.Substring(0, nullIndex);
            else
                return s;
        }
예제 #9
0
        public static unsafe IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size = propertyContainer.GetPropertySize(key);
            long numElements = (long)size / sizeof(IntPtr);
            IntPtr[] ptrs = new IntPtr[numElements];
            byte[] data = InteropTools.ReadBytes(propertyContainer, key);

            fixed (byte* pData = data)
            {
                void** pBS = (void**)pData;
                for (int i = 0; i < numElements; i++)
                    ptrs[i] = new IntPtr(pBS[i]);
            }
            return ptrs;
        }
예제 #10
0
        public static unsafe byte[] ReadBytes(IPropertyContainer propertyContainer, uint key)
        {
            IntPtr size;

            size = propertyContainer.GetPropertySize(key);
            byte[] data = new byte[size.ToInt64()];
            fixed (byte* pData = data)
            {
                propertyContainer.ReadProperty(key, size, pData);
            }
            return data;
        }