public static string GetNameFromGuid(_tagpropertykey key, tag_inner_PROPVARIANT values)
        {
            var    pValues = (IPortableDeviceValues) new PortableDeviceValuesClass();
            string contentTypeName;

            pValues.SetValue(ref key, ref values);
            pValues.GetStringValue(ref key, out contentTypeName);

            return(contentTypeName);
        }
Beispiel #2
0
        public static PropVariant FromValue(PROPVARIANT value)
        {
            IntPtr ptrValue = Marshal.AllocHGlobal(Marshal.SizeOf(value));

            Marshal.StructureToPtr(value, ptrValue, false);

            //
            // Marshal the pointer into our C# object
            //
            return((PropVariant)Marshal.PtrToStructure(ptrValue, typeof(PropVariant)));
        }
        protected static void StringToPropVariant(
            string value,
            out tag_inner_PROPVARIANT propvarValue)

        {
            IPortableDeviceValues pValues =
                (IPortableDeviceValues)
                new PortableDeviceValuesClass();

            pValues.SetStringValue(ref PortableDevicePKeys.WPD_OBJECT_ID, value);

            pValues.GetValue(ref PortableDevicePKeys.WPD_OBJECT_ID, out propvarValue);
        }
Beispiel #4
0
        public static bool HasKeyValue(this IPortableDeviceValues values, PropertyKey findKey)
        {
            uint num = 0;

            values?.GetCount(ref num);
            for (uint i = 0; i < num; i++)
            {
                PropertyKey key = new PropertyKey();
                PROPVARIANT val = new PROPVARIANT();
                values.GetAt(i, ref key, ref val);
                if (key.fmtid == findKey.fmtid && key.pid == findKey.pid)
                {
                    PropVariant pval = val;
                    return(pval.variantType != VarType.VT_ERROR);
                }
            }
            return(false);
        }
Beispiel #5
0
        public void Delete(PortableDevice portableDevice)
        {
            if (portableDevice == null || !portableDevice.IsConnected)
            {
                throw new ArgumentNullException(nameof(portableDevice));
            }

            var variant = new tag_inner_PROPVARIANT();

            StringToPropVariant(Id, out variant);

            IPortableDevicePropVariantCollection objectIds =
                new PortableDevicePropVariantCollection()
                as IPortableDevicePropVariantCollection;

            objectIds.Add(variant);

            portableDevice.Content.Delete(0, objectIds, null);
        }
        public static string GetNameFromGuid(_tagpropertykey key, tag_inner_PROPVARIANT values)
        {
            var pValues = (IPortableDeviceValues) new PortableDeviceValuesClass();
            string contentTypeName;

            pValues.SetValue(ref key, ref values);
            pValues.GetStringValue(ref key, out contentTypeName);

            return contentTypeName;
        }