Exemplo n.º 1
0
        protected unsafe void SetObject(IntPtr guid, object value)
        {
            // NOT WORKING with APPDATA
            var prop = new PropertyPointer();

            InitHeader <PropertyPointer>(ref prop.Header);
            var dataValue = IntPtr.Zero;

            prop.Data = new IntPtr(&dataValue);

            // Free previous application data if any
            Device.GetProperty(guid, new IntPtr(&prop));

            GCHandle handle;

            if (prop.Data.ToInt64() != -1)
            {
                handle = GCHandle.FromIntPtr(prop.Data);
                if (handle.IsAllocated)
                {
                    handle.Free();
                }
            }

            // Set new object value
            handle    = GCHandle.Alloc(value, GCHandleType.Pinned);
            prop.Data = handle.AddrOfPinnedObject();
            Device.SetProperty(guid, new IntPtr(&prop));
        }
Exemplo n.º 2
0
        protected unsafe object GetObject(IntPtr guid)
        {
            // NOT WORKING with APPDATA
            var prop = new PropertyPointer();

            InitHeader <PropertyPointer>(ref prop.Header);
            IntPtr value = IntPtr.Zero;

            prop.Data = new IntPtr(&value);
            Device.GetProperty(guid, new IntPtr(&prop));

            if (prop.Data.ToInt64() == -1)
            {
                return(null);
            }

            var handle = GCHandle.FromIntPtr(prop.Data);

            if (!handle.IsAllocated)
            {
                return(null);
            }

            return(handle.Target);
        }
Exemplo n.º 3
0
        protected unsafe InputRange GetRange(IntPtr guid)
        {
            var prop = new PropertyRange();

            InitHeader <PropertyRange>(ref prop.Header);
            Device.GetProperty(guid, new IntPtr(&prop));
            return(new InputRange(prop));
        }
Exemplo n.º 4
0
        protected unsafe Guid GetGuid(IntPtr guid)
        {
            var propNative = new PropertyGuidAndPath.__Native();

            InitHeader <PropertyGuidAndPath.__Native>(ref propNative.Header);
            Device.GetProperty(guid, new IntPtr(&propNative));
            return(propNative.GuidClass);
        }
Exemplo n.º 5
0
        protected unsafe int GetInt(IntPtr guid, int objCode)
        {
            var prop = new PropertyInt();

            InitHeader <PropertyInt>(ref prop.Header);
            prop.Header.Obj = objCode;
            Device.GetProperty(guid, new IntPtr(&prop));
            return(prop.Data);
        }
Exemplo n.º 6
0
        protected unsafe string GetPath(IntPtr guid)
        {
            var prop       = new PropertyGuidAndPath();
            var propNative = new PropertyGuidAndPath.__Native();

            InitHeader <PropertyGuidAndPath.__Native>(ref propNative.Header);
            Device.GetProperty(guid, new IntPtr(&propNative));
            prop.__MarshalFrom(ref propNative);
            return(prop.Path);
        }
Exemplo n.º 7
0
        protected unsafe string GetString(IntPtr guid, int objectCode)
        {
            var prop       = new PropertyString();
            var propNative = new PropertyString.__Native();

            InitHeader <PropertyString.__Native>(ref propNative.Header);
            propNative.Header.Obj = objectCode;
            Device.GetProperty(guid, new IntPtr(&propNative));
            prop.__MarshalFrom(ref propNative);
            return(prop.Text);
        }