示例#1
0
        public void KnownFolder_GetId()
        {
            IKnownFolderManager manager = ShellMethods.GetKnownFolderManager();
            IKnownFolder        folder  = manager.GetFolder(KnownFolderIds.Windows);

            folder.GetId().Should().Be(KnownFolderIds.Windows);
        }
示例#2
0
        public void KnownFolder_GetId()
        {
            IKnownFolderManager manager = ShellDesktopMethods.GetKnownFolderManager();
            IKnownFolder        folder  = manager.GetFolder(KNOWNFOLDERID.Windows);

            folder.GetId().Should().Be(KNOWNFOLDERID.Windows);
        }
        /// <summary>
        ///     <see cref="KNOWNFOLDER_DEFINITION" />を取得し、
        ///     各プロパティを初期化します。
        /// </summary>
        /// <param name="knownFolderInterface"></param>
        private void Initialize(IKnownFolder knownFolderInterface)
        {
            Contract.Requires(knownFolderInterface != null);

            KNOWNFOLDER_DEFINITION knownFolderDefinition;

            knownFolderInterface.GetFolderDefinition(out knownFolderDefinition);

            try
            {
                this.ParsingName   = PtrToString(knownFolderDefinition.pszParsingName);
                this.CanonicalName = PtrToString(knownFolderDefinition.pszName);
                this.Category      = (KnownFolderCategories)knownFolderDefinition.category;
                this.Description   = PtrToString(knownFolderDefinition.pszDescription);
                this.ParentId      = knownFolderDefinition.fidParent;
                this.RelativePath  = PtrToString(knownFolderDefinition.pszRelativePath);

                InitializeResourceProperties(knownFolderDefinition);

                this.FolderDefinitionFlags = (FolderDefinitionFlags)knownFolderDefinition.kfdFlags;
                this.FileAttributes        = (FileAttributes)knownFolderDefinition.dwAttributes;
                this.FolderTypeId          = knownFolderDefinition.ftidType;
                this.FolderType            = String.Empty;
                this.FolderId = knownFolderInterface.GetId();

                InitializePath(knownFolderInterface);

                this.Redirection = (RedirectionCapability)knownFolderInterface.GetRedirectionCapabilities();
                this.Security    = PtrToString(knownFolderDefinition.pszSecurity);
            }
            finally
            {
                ShellNativeMethods.FreeKnownFolderDefinitionFields(ref knownFolderDefinition);
            }
        }