• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IShellFolder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ShellNode

        public ShellNode(ShellBrowser browser, IntPtr pidl, IntPtr shellFolderPtr)
        {
            this.Browser = browser;

            this.shellFolderPtr = shellFolderPtr;
            this.shellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(shellFolderPtr, typeof(IShellFolder));
            this.SubFiles = new ShellItemCollection(this);
            this.SubFolders = new ShellItemCollection(this);

            PIDLRel = new Pidl(pidl, false);

            Text = "Desktop";
            Path = "Desktop";

            SetAttributesDesktop(this);

            ShFileInfo info = new ShFileInfo();
            Shell32.SHGetFileInfo(PIDLRel.Ptr, 0, ref info, Marshal.SizeOf(info), SHGFI.Pidl | SHGFI.TypeName | SHGFI.SysIconIndex);

            Type = info.TypeName;

            ShellImageList.SetIconIndex(this, info.IconIndex, false);
            ShellImageList.SetIconIndex(this, info.IconIndex, true);

            SortFlag = 1;
        }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:26,代码来源:ShellNode.cs


示例2: FromShellFolder

 public static ExtractIconWrapper FromShellFolder(IShellFolder folder, IntPtr pidl)
 {
     if (folder == null)
     {
         throw new ArgumentNullException("folder");
     }
     if (pidl == IntPtr.Zero)
     {
         throw new ArgumentException("pidl == IntPtr.Zero", "pidl");
     }
     try
     {
         object obj2;
         IntPtr[] apidl = new IntPtr[] { pidl };
         folder.GetUIObjectOf(IntPtr.Zero, 1, apidl, typeof(IExtractIconW).GUID, IntPtr.Zero, out obj2);
         if (obj2 != null)
         {
             return new ExtractIconWrapper((IExtractIconW) obj2);
         }
     }
     catch (FileNotFoundException)
     {
     }
     return null;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:25,代码来源:ExtractIconWrapper.cs


示例3: ShellItem

        internal ShellItem(ShellBrowser browser, IntPtr pidl, IntPtr shellFolderPtr)
        {
            this.browser = browser;

            this.shellFolderPtr = shellFolderPtr;
            this.shellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(shellFolderPtr, typeof(IShellFolder));
            subFiles = new ShellItemCollection(this);
            subFolders = new ShellItemCollection(this);

            pidlRel = new PIDL(pidl, false);

            text = "Desktop";
            path = "Desktop";

            SetAttributesDesktop(this);

            ShellAPI.SHFILEINFO info = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGetFileInfo(pidlRel.Ptr, 0, ref info, ShellAPI.cbFileInfo,
                                   ShellAPI.SHGFI.PIDL | ShellAPI.SHGFI.TYPENAME | ShellAPI.SHGFI.SYSICONINDEX);

            type = info.szTypeName;

            ShellImageList.SetIconIndex(this, info.iIcon, false);
            ShellImageList.SetIconIndex(this, info.iIcon, true);

            sortFlag = 1;
        }
开发者ID:art-drobanov,项目名称:RecoveryStar,代码行数:27,代码来源:ShellItem.cs


示例4: GetChilds

        private static void GetChilds(IShellFolder desktop)
        {
            Console.WriteLine("===============GetChilds================");

            //循环查找子项
            Microsoft.WindowsAPICodePack.Shell.IEnumIDList Enum = null;
            IEnumIDList EnumPtr;
            IntPtr pidlSub;
            uint celtFetched;

            if (desktop.EnumObjects(IntPtr.Zero, ShellNativeMethods.ShellFolderEnumerationOptions.Folders | ShellNativeMethods.ShellFolderEnumerationOptions.IncludeHidden | ShellNativeMethods.ShellFolderEnumerationOptions.Storage, out EnumPtr) == CONST.S_OK)
            {
                while (EnumPtr.Next(1, out pidlSub, out celtFetched) == 0 && celtFetched == CONST.S_FALSE)
                {
                    IntPtr strr;
                    desktop.GetDisplayNameOf(ref pidlSub, (uint)SHGNO.INFOLDER, out strr);
                    string name = Marshal.PtrToStringAuto(strr);

                    //SHFILEINFO info = new SHFILEINFO();
                    //Shell32.SHGetFileInfo(pidlSub, 0, ref info, Marshal.SizeOf(typeof(SHFILEINFO)), SHGFI.PIDL | SHGFI.DISPLAYNAME | SHGFI.ICONLOCATION);

                    //IShellFolder iSub;
                    //desktop.BindToObject(pidlSub, IntPtr.Zero, ref Guids.IID_IShellFolder, out iSub);

                    Console.WriteLine(name);
                }
            }
            Console.WriteLine();
            Console.WriteLine();
        }
开发者ID:uonun,项目名称:TaggableShell,代码行数:30,代码来源:Program.cs


示例5: CreateShellView

        internal override IShellView CreateShellView(IShellFolder folder)
        {
            //  Setup create info for a new default folder view.
            var createInfo = new SFV_CREATE
            {
                cbSize = (uint) Marshal.SizeOf(typeof (SFV_CREATE)),
                pshf = folder,
                psvOuter = null,
                psfvcb = null
            };

            //  TODO: IMPORTANT: This is the function that's failing now for creating the 
            //  view, it seems that it could be due to not providing psvOuter (which may be
            //  required as we're not far off being a common dialog) or more likely because we
            //  are not providing the callback. Try both...
            //  NOTE: A quick test shows it's unlikely to be the psvOuter, try the CB.
            //  NOTE: adding the callback hasn't helped, we can try the alternative call
            //  which is shcreateshellfolderviewex
            //  NOTE: None of those suggestions worked.
            IShellView view;
            if (Shell32.SHCreateShellFolderView(ref createInfo, out view) != WinError.S_OK)
            {
                throw new Exception("An error occured creating the default folder view.");
            }

            return view;
        }
开发者ID:mleo1,项目名称:sharpshell,代码行数:27,代码来源:DefaultNamespaceFolderView.cs


示例6: ShellFolder

 internal ShellFolder(IShellItem shellItem, IShellFolder shellFolder, ShellItemKnownInfo knownInfo)
     : base(GetShellItemFromFolder(shellItem, shellFolder), knownInfo)
 {
     if (shellFolder == null)
     {
         shellFolder = (IShellFolder)shellItem.BindToHandler(null, ShellConsts.BHID_SFObject, typeof(IShellFolder).GUID);
     }
     NativeFolder = shellFolder;
 }
开发者ID:poizan42,项目名称:PSShellProvider,代码行数:9,代码来源:ShellFolder.cs


示例7: GetShellItemFromFolder

 private static IShellItem GetShellItemFromFolder(IShellItem shellItem, IShellFolder shellFolder)
 {
     if (shellItem == null && shellFolder == null)
         throw new ArgumentNullException("shellItem, shellFolder", "shellItem and shellFolder cannot both be null");
     if (shellItem != null)
         return shellItem;
     IdList pidl = SHGetIDListFromObject(shellFolder);
     return SHCreateItemFromIDList<IShellItem>(pidl);
 }
开发者ID:poizan42,项目名称:PSShellProvider,代码行数:9,代码来源:ShellFolder.cs


示例8: GetNameByIShell

 /// <summary>
 /// 获取显示名称
 /// </summary>
 public static string GetNameByIShell(IShellFolder Root, IntPtr pidlSub)
 {
     IntPtr strr = Marshal.AllocCoTaskMem(MAX_PATH * 2 + 4);
     Marshal.WriteInt32(strr, 0, 0);
     StringBuilder buf = new StringBuilder(MAX_PATH);
     Root.GetDisplayNameOf(pidlSub, SHGNO.INFOLDER, strr);
     Shlwapi.StrRetToBuf(strr, pidlSub, buf, MAX_PATH);
     return buf.ToString();
 }
开发者ID:uonun,项目名称:TaggableShell,代码行数:12,代码来源:ShellExtension.cs


示例9: ShellItem

        internal ShellItem(ShellBrowser browser, ShellAPI.CSIDL specialFolder)
        {
            IntPtr pidl = IntPtr.Zero;
            ShellAPI.SHGetSpecialFolderLocation(IntPtr.Zero, specialFolder, out pidl);
            //
            IntPtr shellFolderPtr;
            this.browser = browser;
            //
            if (specialFolder == ShellAPI.CSIDL.DESKTOP)
            {
                ShellAPI.SHGetDesktopFolder(out shellFolderPtr);
                //
                this.shellFolderPtr = shellFolderPtr;
                this.shellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(shellFolderPtr, typeof(IShellFolder));
            }
            else
            {
                this.shellFolder = GetShellFolderFromPidl(pidl, out shellFolderPtr);
                //
                this.parentItem = browser.DesktopItem;
            }
            //
            subFiles = new ShellItemCollection(this);
            subFolders = new ShellItemCollection(this);

            pidlRel = new PIDL(pidl, false);

            ShellAPI.SHFILEINFO info = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGetFileInfo(pidlRel.Ptr, 0, ref info, ShellAPI.cbFileInfo,
                ShellAPI.SHGFI.PIDL | ShellAPI.SHGFI.TYPENAME | ShellAPI.SHGFI.SYSICONINDEX | ShellAPI.SHGFI.DISPLAYNAME);

            type = info.szTypeName;
            text = info.szDisplayName;
            //
            StringBuilder pathBuilder = new StringBuilder(ShellAPI.MAX_PATH);
            ShellAPI.SHGetFolderPath(
                    IntPtr.Zero, specialFolder,
                    IntPtr.Zero, ShellAPI.SHGFP.TYPE_CURRENT, pathBuilder);
            this.path = pathBuilder.ToString();
            //
            if (specialFolder == ShellAPI.CSIDL.DESKTOP)
            {
                ShellImageList.SetIconIndex(this, info.iIcon, false);
                ShellImageList.SetIconIndex(this, info.iIcon, true);
                //
                SetAttributesDesktop(this);
            }
            else
            {
                SetAttributesFolder(this);
                SetInfo(this);
            }
            sortFlag = 1;
        }
开发者ID:desperate-man,项目名称:FileRandomizer3000,代码行数:54,代码来源:ShellItem.cs


示例10: ShellItem

 public ShellItem(IShellFolder folder, IntPtr relativePidl)
 {
     if (folder == null)
     {
         throw new ArgumentNullException("folfer");
     }
     if (relativePidl == IntPtr.Zero)
     {
         throw new ArgumentException("relativePidl == IntPtr.Zero", "relativePidl");
     }
     this.FAbsolutePidl = GetAbsolutePidl(folder, relativePidl);
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:12,代码来源:ShellItem.cs


示例11: GetContextMenuInterfaces

        private static bool GetContextMenuInterfaces(IShellFolder oParentFolder, IntPtr PIDLs, out IntPtr ctxMenuPtr)
        {
            var arrPidLs = new IntPtr[1];
            arrPidLs[0] = PIDLs;
            var nResult = oParentFolder.GetUIObjectOf(IntPtr.Zero, (uint) arrPidLs.Length, arrPidLs, ref _iidIContextMenu, IntPtr.Zero, out ctxMenuPtr);
            if (SOk == nResult)
            {
                _oContextMenu = (IContextMenu) Marshal.GetTypedObjectForIUnknown(ctxMenuPtr, typeof (IContextMenu));

                return true;
            }
            ctxMenuPtr = IntPtr.Zero;
            _oContextMenu = null;
            return false;
        }
开发者ID:Belial09,项目名称:Fesslersoft-WindowsAPI,代码行数:15,代码来源:ContextMenu.cs


示例12: GetContextMenuInterfaces

        /// <summary>Gets the interfaces to the context menu</summary>
        /// <param name="oParentFolder">Parent folder</param>
        /// <param name="arrPIDLs">PIDLs</param>
        /// <returns>true if it got the interfaces, otherwise false</returns>
        private bool GetContextMenuInterfaces(IShellFolder oParentFolder, IntPtr[] arrPIDLs, out IntPtr ctxMenuPtr)
        {
            int nResult = oParentFolder.GetUIObjectOf(
                IntPtr.Zero,
                (uint)arrPIDLs.Length,
                arrPIDLs,
                ref IID_IContextMenu,
                IntPtr.Zero,
                out ctxMenuPtr);

            if (S_OK == nResult)
            {
                _oContextMenu = (IContextMenu)Marshal.GetTypedObjectForIUnknown(ctxMenuPtr, typeof(IContextMenu));

                return true;
            }
            else
            {
                ctxMenuPtr = IntPtr.Zero;
                _oContextMenu = null;
                return false;
            }
        }
开发者ID:SunboX,项目名称:Easygoing.FiddlerCache,代码行数:27,代码来源:ShellContextMenu.cs


示例13: GetContextMenuInterfaces

        /// <summary>Gets the interfaces to the context menu</summary>
        /// <param name="oParentFolder">Parent folder</param>
        /// <param name="arrPIDLs">PIDLs</param>
        /// <returns>true if it got the interfaces, otherwise false</returns>
        private bool GetContextMenuInterfaces(IShellFolder oParentFolder, IntPtr[] arrPIDLs)
        {
            IntPtr pUnknownContextMenu = IntPtr.Zero;

            int nResult = oParentFolder.GetUIObjectOf(
                IntPtr.Zero,
                (uint)arrPIDLs.Length,
                arrPIDLs,
                ref IID_IContextMenu,
                IntPtr.Zero,
                out pUnknownContextMenu);

            if (S_OK == nResult)
            {
                _oContextMenu = (IContextMenu)Marshal.GetTypedObjectForIUnknown(pUnknownContextMenu, typeof(IContextMenu));

                IntPtr pUnknownContextMenu2 = IntPtr.Zero;
                if (S_OK == Marshal.QueryInterface(pUnknownContextMenu, ref IID_IContextMenu2, out pUnknownContextMenu2))
                {
                    _oContextMenu2 = (IContextMenu2)Marshal.GetTypedObjectForIUnknown(pUnknownContextMenu2, typeof(IContextMenu2));
                }
                IntPtr pUnknownContextMenu3 = IntPtr.Zero;
                if (S_OK == Marshal.QueryInterface(pUnknownContextMenu, ref IID_IContextMenu3, out pUnknownContextMenu3))
                {
                    _oContextMenu3 = (IContextMenu3)Marshal.GetTypedObjectForIUnknown(pUnknownContextMenu3, typeof(IContextMenu3));
                }

                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:38,代码来源:ShellContextMenu.cs


示例14: CheckDisplayName

 private static bool CheckDisplayName(IShellFolder shellFolder, IntPtr pIDLLast, Regex re) {
     if(pIDLLast != IntPtr.Zero) {
         STRRET strret;
         uint uFlags = 0;
         StringBuilder pszBuf = new StringBuilder(260);
         if(shellFolder.GetDisplayNameOf(pIDLLast, uFlags, out strret) == 0) {
             PInvoke.StrRetToBuf(ref strret, pIDLLast, pszBuf, pszBuf.Capacity);
         }
         if(pszBuf.Length > 0) {
             return re.IsMatch(pszBuf.ToString());
         }
     }
     return false;
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:14,代码来源:QTButtonBar.cs


示例15: GetDesktopFolder

        /// <summary>
        /// Gets the desktop folder
        /// </summary>
        /// <returns>IShellFolder for desktop folder</returns>
        private IShellFolder GetDesktopFolder()
        {
            IntPtr pUnkownDesktopFolder = IntPtr.Zero;

            if (null == _oDesktopFolder)
            {
                // Get desktop IShellFolder
                int nResult = SHGetDesktopFolder(out pUnkownDesktopFolder);
                if (S_OK != nResult)
                {
                    throw new ShellContextMenuException("Failed to get the desktop shell folder");
                }
                _oDesktopFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(pUnkownDesktopFolder, typeof(IShellFolder));
            }

            return _oDesktopFolder;
        }
开发者ID:xanthalas,项目名称:Rummage,代码行数:21,代码来源:ShellContextMenu.cs


示例16: GetParentFolder

        /// <summary>
        /// Gets the parent folder
        /// </summary>
        /// <param name="folderName">Folder path</param>
        /// <returns>IShellFolder for the folder (relative from the desktop)</returns>
        private IShellFolder GetParentFolder(string folderName)
        {
            if (null == _oParentFolder)
            {
                IShellFolder oDesktopFolder = GetDesktopFolder();
                if (null == oDesktopFolder)
                {
                    return null;
                }

                // Get the PIDL for the folder file is in
                IntPtr pPIDL = IntPtr.Zero;
                uint pchEaten = 0;
                SFGAO pdwAttributes = 0;
                int nResult = oDesktopFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, folderName, ref pchEaten, out pPIDL, ref pdwAttributes);
                if (S_OK != nResult)
                {
                    return null;
                }

                IntPtr pStrRet = Marshal.AllocCoTaskMem(MAX_PATH * 2 + 4);
                Marshal.WriteInt32(pStrRet, 0, 0);
                nResult = _oDesktopFolder.GetDisplayNameOf(pPIDL, SHGNO.FORPARSING, pStrRet);
                StringBuilder strFolder = new StringBuilder(MAX_PATH);
                StrRetToBuf(pStrRet, pPIDL, strFolder, MAX_PATH);
                Marshal.FreeCoTaskMem(pStrRet);
                pStrRet = IntPtr.Zero;
                _strParentFolder = strFolder.ToString();

                // Get the IShellFolder for folder
                IntPtr pUnknownParentFolder = IntPtr.Zero;
                nResult = oDesktopFolder.BindToObject(pPIDL, IntPtr.Zero, ref IID_IShellFolder, out pUnknownParentFolder);
                // Free the PIDL first
                Marshal.FreeCoTaskMem(pPIDL);
                if (S_OK != nResult)
                {
                    return null;
                }
                _oParentFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(pUnknownParentFolder, typeof(IShellFolder));
            }

            return _oParentFolder;
        }
开发者ID:xanthalas,项目名称:Rummage,代码行数:48,代码来源:ShellContextMenu.cs


示例17: SHGetRealIDL

 public static extern Int32 SHGetRealIDL(IShellFolder psf, IntPtr pidlSimple, out IntPtr ppidlReal);
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:1,代码来源:NativeMethods.cs


示例18: PIDLToShellFolder

 static IShellFolder PIDLToShellFolder(IShellFolder parent, IntPtr pidl)
 {
     IShellFolder folder;
     var result = parent.BindToObject(pidl, null, ref IID_IShellFolder, out folder);
     Marshal.ThrowExceptionForHR((int)result);
     return folder;
 }
开发者ID:justwee,项目名称:WPF-Projects,代码行数:7,代码来源:ShowSelectedInExplorer.cs


示例19: GetShellFolderChildrenRelativePIDL

        static IntPtr GetShellFolderChildrenRelativePIDL(IShellFolder parentFolder, string displayName)
        {
            var bindCtx = NativeMethods.CreateBindCtx();

            uint pchEaten;
            uint pdwAttributes = 0;
            IntPtr ppidl;
            parentFolder.ParseDisplayName(IntPtr.Zero, null, displayName, out pchEaten, out ppidl, ref pdwAttributes);

            return ppidl;
        }
开发者ID:justwee,项目名称:WPF-Projects,代码行数:11,代码来源:ShowSelectedInExplorer.cs


示例20: GetDisplayName

 public static string GetDisplayName(IShellFolder shellFolder, IntPtr pIDLLast, bool fDisplayName) {
     STRRET strret;
     uint uFlags = fDisplayName ? 0 : 0x8000u;
     StringBuilder pszBuf = new StringBuilder(260);
     if(shellFolder.GetDisplayNameOf(pIDLLast, uFlags, out strret) == 0) {
         PInvoke.StrRetToBuf(ref strret, pIDLLast, pszBuf, pszBuf.Capacity);
     }
     return pszBuf.ToString();
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:9,代码来源:ShellMethods.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IShellItem类代码示例发布时间:2022-05-24
下一篇:
C# IShellContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap