Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hivePath"></param>
        /// <returns></returns>
        public static FileMRU[] Get(string hivePath)
        {
            if (RegistryHelper.isCorrectHive(hivePath, "NTUSER.DAT"))
            {
                string         user     = RegistryHelper.GetUserHiveOwner(hivePath);
                List <FileMRU> fileList = new List <FileMRU>();

                byte[]   bytes     = RegistryHelper.GetHiveBytes(hivePath);
                NamedKey OfficeKey = RegistryHelper.GetOfficeKey(bytes, hivePath);

                foreach (NamedKey nk in OfficeKey.GetSubKeys(bytes))
                {
                    if (nk.Name == "Word" || nk.Name == "Excel" || nk.Name == "PowerPoint")
                    {
                        foreach (NamedKey k in nk.GetSubKeys(bytes))
                        {
                            if (k.Name == "File MRU")
                            {
                                foreach (ValueKey vk in k.GetValues(bytes))
                                {
                                    if (vk.Name != "Max Display")
                                    {
                                        fileList.Add(new FileMRU(user, (string)vk.GetData(bytes)));
                                    }
                                }
                            }
                        }
                    }
                }
                return(fileList.ToArray());
            }
            else
            {
                throw new Exception("Invalid NTUSER.DAT hive provided to -HivePath parameter.");
            }
        }