Example #1
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            properties.GetSupportedProperties(objectId, out IPortableDeviceKeyCollection keys);
            properties.GetValues(objectId, keys, out IPortableDeviceValues values);
            // Get the name of the object
            var property = new _tagpropertykey
            {
                fmtid = CreateFmtidGuid(),
                pid   = 4
            };

            values.GetStringValue(property, out string name);
            // Get the type of the object
            property = new _tagpropertykey
            {
                fmtid = CreateFmtidGuid(),
                pid   = 7
            };
            values.GetGuidValue(property, out Guid contentType);
            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name));
            }
            property.pid = 12;//WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            return(new PortableDeviceFile(objectId, name));
        }
Example #2
0
        public DeviceProperties(IPortableDeviceProperties deviceProperties)
        {
            IPortableDeviceKeyCollection keys;

            deviceProperties.GetSupportedProperties(Item.RootId, out keys);
            deviceProperties.GetValues(Item.RootId, keys, out this.values);
        }
Example #3
0
        private static string GetNameById(string objectId, IPortableDeviceProperties properties)
        {
            IPortableDeviceValues objectValues;

            properties.GetValues(objectId, null, out objectValues);
            return(GetNameProperty(objectValues));
        }
Example #4
0
        private void CreateTree(MTPFileNode parentNode, IPortableDeviceContent content, IPortableDeviceProperties properties, IAsyncProgress asyn)
        {
            List <string> objectsId = GetChildrenObjectIds(content, parentNode.Id);

            if (objectsId != null && objectsId.Count > 0)
            {
                foreach (string objectId in objectsId)
                {
                    IPortableDeviceValues objectValues;
                    properties.GetValues(objectId, null, out objectValues);
                    MTPFileNode fileNode = new MTPFileNode()
                    {
                        Type = GetFileTypeProperty(objectValues),
                        Name = GetFullNameProperty(objectValues),
                        //FileSize = GetFileSizeProperty(objectValues),
                        Id        = objectId,
                        Childrens = new List <MTPFileNode>(),
                        Parent    = parentNode,
                        //Level = parentNode.Level + 1
                    };

                    parentNode.Childrens.Add(fileNode);

                    //asyn.Advance(0, string.Format(LanguageHelper.Get("LANGKEY_HuoQuJieDian_00555"), fileNode.Name));

                    if (fileNode.Type != MTPFileNodeType.File)
                    {
                        CreateTree(fileNode, content, properties, asyn);
                    }
                }
            }
        }
Example #5
0
        private static MTPFileNodeType GetFileTypeById(string objectId, IPortableDeviceProperties properties)
        {
            IPortableDeviceValues objectValues;

            properties.GetValues(objectId, null, out objectValues);
            return(GetFileTypeProperty(objectValues));
        }
Example #6
0
        public void Refresh()
        {
            if (this.Count > 0)
            {
                this.Clear();
            }

            IPortableDeviceProperties properties = null;

            this.content.Properties(out properties);

            IPortableDeviceValues values = null;

            properties.GetValues(this.objectID, null, out values);

            var count = 0U;

            values.GetCount(ref count);

            var key     = new _tagpropertykey();
            var propVar = new tag_inner_PROPVARIANT();

            for (var i = 0U; i < count; i++)
            {
                values.GetAt(i, ref key, ref propVar);
                this.Add(WpdProperty.Create(key, propVar));
            }
        }
Example #7
0
        public ObjectProperties(IPortableDeviceProperties deviceProperties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            deviceProperties.GetSupportedProperties(objectId, out keys);
            deviceProperties.GetValues(objectId, keys, out this.values);
        }
Example #8
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            // Check if the object is folder or file
            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name, 0));
            }
            else
            {
                // Get the name of the object
                property       = new _tagpropertykey();
                property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                          0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
                property.pid = 12;
                values.GetStringValue(property, out name);

                // Get the size of the object
                ulong size;
                property       = new _tagpropertykey();
                property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                          0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
                property.pid = 11;
                values.GetUnsignedLargeIntegerValue(property, out size);

                return(new PortableDeviceFile(objectId, name, size));
            }
        }
Example #9
0
        public static void WriteObject(IPortableDeviceProperties deviceProperties, string objectId)
        {
#if COM_TRACE_ENABLE
            IPortableDeviceKeyCollection keys;
            deviceProperties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            deviceProperties.GetValues(objectId, keys, out values);

            WriteObject(values);
#endif
        }
Example #10
0
        public static void WriteObject(IPortableDeviceProperties deviceProperties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            deviceProperties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            deviceProperties.GetValues(objectId, keys, out values);

            InternalWriteObject(values);
        }
        /**
         * Wrap Object
         */
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name     = string.Empty;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 12;
            try { values.GetStringValue(property, out name); }
            catch (Exception)
            {
                property.pid = 4;
                try { values.GetStringValue(property, out name); }
                catch (Exception) { name = "Unknown"; }
            }


            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 7;
            values.GetGuidValue(property, out contentType);

            var folderType     = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C, 0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98, 0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name));
            }

            // Get the size of the object
            long objSiz;

            property       = new _tagpropertykey();
            property.fmtid = new Guid("EF6B490D-5CD8-437A-AFFC-DA8B60EE4A3C");
            property.pid   = 11; //WPD_OBJECT_SIZE;
            values.GetSignedLargeIntegerValue(property, out objSiz);

            return(new PortableDeviceFile(objectId, name, objSiz));
        }
        private PortableDeviceObject ExtractInformation(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            Guid guid;

            values.GetGuidValue(ref PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out guid);

            return(PortableDeviceObjectFactory.Instance.CreateInstance(guid, values));
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            PortableDeviceApiLib.IPortableDeviceKeyCollection portableDeviceKeyCollection;
            PortableDeviceApiLib.IPortableDeviceValues        portableDeviceValue;
            Guid guid;

            properties.GetSupportedProperties(objectId, out portableDeviceKeyCollection);
            properties.GetValues(objectId, portableDeviceKeyCollection, out portableDeviceValue);

            string empty = string.Empty;

            PortableDeviceApiLib._tagpropertykey __tagpropertykey = new PortableDeviceApiLib._tagpropertykey()
            {
                fmtid = new Guid(-278181619, 23768, 17274, 175, 252, 218, 139, 96, 238, 74, 60)
            };

            __tagpropertykey = new PortableDeviceApiLib._tagpropertykey()
            {
                fmtid = new Guid(-278181619, 23768, 17274, 175, 252, 218, 139, 96, 238, 74, 60),
                pid   = 7
            };

            PortableDeviceApiLib._tagpropertykey __tagpropertykey1 = __tagpropertykey;
            portableDeviceValue.GetGuidValue(ref __tagpropertykey1, out guid);

            Guid guid1 = new Guid(669180818, 41233, 18656, 171, 12, 225, 119, 5, 160, 95, 133);
            Guid guid2 = new Guid(-1712520864, 6143, 19524, 157, 152, 29, 122, 111, 148, 25, 33);

            try
            {
                __tagpropertykey.pid = 12;
                PortableDeviceApiLib._tagpropertykey __tagpropertykey2 = __tagpropertykey;
                portableDeviceValue.GetStringValue(ref __tagpropertykey2, out empty);
            }
            catch
            {
            }

            if (!(guid == guid1) && !(guid == guid2))
            {
                return(new PortableDeviceFile(objectId, empty));
            }

            return(new PortableDeviceFolder(objectId, empty));
        }
Example #14
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new PortableDeviceFolder(objectId, name));
            }

            //string fullName;
            property.pid = 12;//WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            return(new PortableDeviceFile(objectId, name));
        }
Example #15
0
        /// <summary>
        /// オブジェクトのプロパティ値を列挙します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="properties">プロパティ情報。</param>
        /// <returns>プロパティ値のコレクション。</returns>
        internal static IEnumerable <WpdPropertyValue> EnumValues(string id, IPortableDeviceProperties properties)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(id, out keys);

            IPortableDeviceValues values;

            properties.GetValues(id, keys, out values);

            uint count = 0;

            values.GetCount(ref count);

            var key  = new _tagpropertykey();
            var info = new tag_inner_PROPVARIANT();

            for (uint i = 0; i < count; ++i)
            {
                values.GetAt(i, ref key, ref info);
                yield return(new WpdPropertyValue(key, info, values));
            }
        }
Example #16
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);


            string name = string.Empty;

            values.GetStringValue(ref PortableDeviceConstants.WPD_OBJECT_NAME, out name);

            // Get the type of the object
            Guid contentType;

            values.GetGuidValue(PortableDeviceConstants.WPD_OBJECT_CONTENT_TYPE, out contentType);


            try
            {
                values.GetStringValue(PortableDeviceConstants.WPD_OBJECT_ORIGINAL_FILE_NAME, out name);
            }
            catch (Exception x)
            {
                x.ToString();
            }

            if (contentType == PortableDeviceConstants.WPD_CONTENT_TYPE_FOLDER || contentType == PortableDeviceConstants.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT)
            {
                return(new PortableDeviceFolder(objectId, name));
            }

            return(new PortableDeviceFile(objectId, name));
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                                                       string objectId)
        {
            if (string.IsNullOrEmpty(objectId))
            {
                throw new ArgumentNullException(nameof(objectId));
            }

            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            string name;

            // Get the name of the object
            values.GetStringValue(PortableDevicePKeys.WPD_OBJECT_NAME, out name);

            // Get the type of the object
            Guid contentType;

            values.GetGuidValue(PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out contentType);

            if (contentType == PortableDeviceGuids.WPD_CONTENT_TYPE_FOLDER ||
                contentType == PortableDeviceGuids.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT)
            {
                return(new PortableDeviceFolder(objectId, name));
            }
            string fileName;

            values.GetStringValue(PortableDevicePKeys.WPD_OBJECT_ORIGINAL_FILE_NAME, out fileName);
            return(new PortableDeviceFile(objectId, fileName));
        }
Example #18
0
        private PortableDeviceObject WrapObject(IPortableDeviceProperties properties, string objectID)
        {
            properties.GetSupportedProperties(objectID, out IPortableDeviceKeyCollection keys);

            properties.GetValues(objectID, keys, out IPortableDeviceValues values);

            try
            {
                // Get the type of the object
                Guid contentType = Guid.Empty;
                try { values.GetGuidValue(GlobalVar.WPD_OBJECT_CONTENT_TYPE, out contentType); }
                catch (Exception ex) { Debug.WriteLine(ex.Message); }

                string name = "";

                if (contentType == GlobalVar.WPD_CONTENT_TYPE_FOLDER_GUID || contentType == GlobalVar.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT_GUID)
                {
                    // Get the name of the folder/storage
                    try { values.GetStringValue(GlobalVar.WPD_OBJECT_NAME, out name); }
                    catch (Exception ex) { Debug.WriteLine(ex.Message); }

                    return(new PortableDeviceFolder(objectID, name));
                }

                // Get the name of the file
                try { values.GetStringValue(GlobalVar.WPD_OBJECT_ORIGINAL_FILE_NAME, out name); }
                catch (Exception ex) { Debug.WriteLine(ex.Message); }

                return(new PortableDeviceFile(objectID, name));
            }
            finally
            {
                Marshal.ReleaseComObject(keys);
                Marshal.ReleaseComObject(values);
            }
        }
        protected static new NwdPortableDeviceObject WrapObject(IPortableDeviceProperties properties,
                       string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            //Get the name of the object
            string name;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A,
                                      0xAF, 0xFC, 0xDA, 0x8B, 0x60,
                                      0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A,
                                      0xAF, 0xFC, 0xDA, 0x8B, 0x60,
                                      0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0,
                                      0xAB, 0x0C, 0xE1, 0x77, 0x05,
                                      0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44,
                                          0x9D, 0x98, 0x1D, 0x7A, 0x6F,
                                          0x94, 0x19, 0x21);

            if (contentType == folderType ||
                contentType == functionalType)
            {
                return new NwdPortableDeviceFolder(objectId, name);
            }
            //TODO: LICENSE NOTES
            //begin test edit
            //per: http://stackoverflow.com/questions/18059234/get-full-name-of-a-file-on-a-windows-portable-device
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A,
                                      0xAF, 0xFC, 0xDA, 0x8B, 0x60,
                                      0xEE, 0x4A, 0x3C);
            property.pid = 12; //WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            //end test edit

            return new NwdPortableDeviceFile(objectId, name);
        }
Example #20
0
        private TransFileObject WrapObject(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;

            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;

            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var    property = new _tagpropertykey();

            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 4;

            try {
                values.GetStringValue(property, out name);
            }
            catch (COMException e) {
                name = "(non name)";
            }

            // Get the original name of the object
            string OriginalName;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 12;
            try {
                values.GetStringValue(property, out OriginalName);
            }
            catch (COMException e) {
                OriginalName = "";
            }

            // Get last write time
            DateTime updatetime = new DateTime();

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 19;
            try {
                string value;
                values.GetStringValue(property, out value);
                string format = "yyyy/MM/dd:HH:mm:ss.fff";
                updatetime = DateTime.ParseExact(value, format, null);
            }
            catch (COMException e) {
                //updatetime = DateTime.Now;
            }

            // Get the type of the object
            Guid contentType;

            property       = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid   = 7;
            try {
                values.GetGuidValue(property, out contentType);
            }
            catch (COMException e) {
                return(new TransFileObject(name, null, updatetime, TransFileObject.ObjectKind.DIR));
            }

            Guid folderType     = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C, 0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            Guid functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98, 0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return(new TransFileObject(name, objectId, updatetime, TransFileObject.ObjectKind.DIR));
            }

            if (OriginalName.CompareTo("") != 0)
            {
                name = OriginalName;
            }

            return(new TransFileObject(name, objectId, updatetime, TransFileObject.ObjectKind.FILE));
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
            string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            string date;
            string size;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return new PortableDeviceFolder(objectId, name, "", "", 0);
            }

            property.pid = 12;//WPD_OBJECT_ORIGINAL_FILE_NAME
            values.GetStringValue(property, out name);
            try
            {
                property.pid = 19;//WPD_OBJECT_DATE_MODIFIED
                values.GetStringValue(property, out date);
            }
            catch (Exception ex)
            {
                property.pid = 18;//WPD_OBJECT_DATE_MODIFIED
                values.GetStringValue(property, out date);
            }
            property.pid = 11;//WPD_OBJECT_SIZE
            values.GetStringValue(property, out size);
            return new PortableDeviceFile(objectId, name, date, size, Int32.Parse(size));
        }
Example #22
0
        /// <summary>
        /// オブジェクトのプロパティ値を列挙します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="properties">プロパティ情報。</param>
        /// <returns>プロパティ値のコレクション。</returns>
        internal static IEnumerable<WpdPropertyValue> EnumValues( string id, IPortableDeviceProperties properties )
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties( id, out keys );

            IPortableDeviceValues values;
            properties.GetValues( id, keys, out values );

            uint count = 0;
            values.GetCount( ref count );

            var key  = new _tagpropertykey();
            var info = new tag_inner_PROPVARIANT();

            for( uint i = 0; i < count; ++i )
            {
                values.GetAt( i, ref key, ref info );
                yield return new WpdPropertyValue( key, info, values );
            }
        }
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties, 
            string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            // Get the name of the object
            string name;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            values.GetStringValue(property, out name);

            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType  || contentType == functionalType)
            {
                return new PortableDeviceFolder(objectId, name);
            }

            return new PortableDeviceFile(objectId, name);
        }
Example #24
0
        private static PortableDeviceObject WrapObject(IPortableDeviceProperties properties,
            string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);


            uint count = 0;
            keys.GetCount(ref count);
            for (uint i = 0; i < count; i++)
            {
                var property_info = new PortableDeviceApiLib._tagpropertykey();
                keys.GetAt(i, ref property_info);
                Console.WriteLine(property_info.fmtid.ToString() + "    " + property_info.pid.ToString());
            }
            //Console.ReadLine();
            //return;
            // Get the name of the object
            string name;
            var property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 4;
            try
            {
                values.GetStringValue(property, out name);
            }
            catch (Exception ex)
            {
                try
                {
                    property.pid = 12;
                    values.GetStringValue(property, out name);
                }
                catch
                {
                    name = "ERROR-NOT-FOUND";
                }
            }
            // Get the type of the object
            Guid contentType;
            property = new _tagpropertykey();
            property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC,
                                      0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C);
            property.pid = 7;
            values.GetGuidValue(property, out contentType);

            var folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C,
                                      0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85);
            var functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98,
                                          0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21);

            if (contentType == folderType || contentType == functionalType)
            {
                return new PortableDeviceFolder(objectId, name);
            }

            return new PortableDeviceFile(objectId, name);
        }
Example #25
0
        private PortableDeviceObject ExtractInformation(IPortableDeviceProperties properties, string objectId)
        {
            IPortableDeviceKeyCollection keys;
            properties.GetSupportedProperties(objectId, out keys);

            IPortableDeviceValues values;
            properties.GetValues(objectId, keys, out values);

            Guid guid;
            values.GetGuidValue(ref PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out guid);

            return PortableDeviceObjectFactory.Instance.CreateInstance(guid, values);
        }