当前位置: 首页>>代码示例>>C#>>正文


C# IShellFolder.GetAttributesOf方法代码示例

本文整理汇总了C#中IShellFolder.GetAttributesOf方法的典型用法代码示例。如果您正苦于以下问题:C# IShellFolder.GetAttributesOf方法的具体用法?C# IShellFolder.GetAttributesOf怎么用?C# IShellFolder.GetAttributesOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IShellFolder的用法示例。


在下文中一共展示了IShellFolder.GetAttributesOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShellItem

        /// <summary>
        /// Constructor. Create a sub-item shell item object.
        /// </summary>
        /// <param name="shDesktop">IShellFolder interface of the Desktop</param>
        /// <param name="pIDL">The fully qualified PIDL for this shell item</param>
        /// <param name="shParent">The ShellItem object for this item's parent</param>
        public ShellItem(IShellFolder shDesktop, IntPtr pIDL, ShellItem shParent)
        {
            // We need the Desktop shell item to exist first.
            if (m_bHaveRootShell == false)
                throw new Exception("The root shell item must be created before creating a sub-item");

            // Create the FQ PIDL for this new item.
            m_pIDL = NativeShellApi.ILCombine(shParent.PIDL, pIDL);

            // Get the properties of this item.
            SFGAOF uFlags = SFGAOF.SFGAO_FOLDER | SFGAOF.SFGAO_HASSUBFOLDER;

            // Here we get some basic attributes.
            shDesktop.GetAttributesOf(1, out m_pIDL, out uFlags);
            IsFolder = Convert.ToBoolean(uFlags & SFGAOF.SFGAO_FOLDER);
            HasSubFolder = Convert.ToBoolean(uFlags & SFGAOF.SFGAO_HASSUBFOLDER);

            // Now we want to get extended attributes such as the icon index etc.
            SHFILEINFO shInfo = new SHFILEINFO();
            SHGFI vFlags =
                SHGFI.SHGFI_SMALLICON |
                SHGFI.SHGFI_SYSICONINDEX |
                SHGFI.SHGFI_PIDL |
                SHGFI.SHGFI_DISPLAYNAME;
            NativeShellApi.SHGetFileInfo(m_pIDL, 0, out shInfo, (uint)Marshal.SizeOf(shInfo), vFlags);
            DisplayName = shInfo.szDisplayName;
            IconIndex = shInfo.iIcon;
            Path = GetPath();

            // Create the IShellFolder interface for this item.
            if (IsFolder)
            {
                uint hRes = shParent.m_shShellFolder.BindToObject(pIDL, IntPtr.Zero, ref NativeShellApi.IID_IShellFolder, out m_shShellFolder);
                if (hRes != 0)
                    Marshal.ThrowExceptionForHR((int)hRes);
            }
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:43,代码来源:ShellItem.cs


注:本文中的IShellFolder.GetAttributesOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。