Skip to main content

ShellFolder

Trait ShellFolder 

Source
pub trait ShellFolder {
Show 13 methods // Required methods fn parse_display_name( &self, hwnd: HWND, display_name: PCWSTR, ) -> Result<(usize, RelativeIDList)>; fn compare_ids( &self, param: CompareIDs, pidl1: &RelativeIDList, pidl2: &RelativeIDList, ) -> Result<Ordering>; fn get_attributes_of( &self, children: &[ChildIDRef<'_>], mask: ItemAttributes, ) -> Result<ItemAttributes>; fn get_display_name_of( &self, pidl: ChildIDRef<'_>, uflags: SHGDNF, ) -> Result<BSTR>; // Provided methods fn from_desktop() -> Result<IShellFolder> { ... } fn from_id_list(pidl: &RelativeIDList) -> Result<IShellFolder> { ... } fn from_path_w(hwnd: HWND, path: PCWSTR) -> Result<IShellFolder> { ... } fn from_fs_any(hwnd: HWND) -> Result<IShellFolder> { ... } fn parse_display_name_to_id_list( &self, hwnd: HWND, display_name: PCWSTR, ) -> Result<RelativeIDList> { ... } fn is_child_folder(&self, child: ChildIDRef<'_>) -> bool { ... } fn is_child_fs_folder(&self, child: ChildIDRef<'_>) -> bool { ... } fn are_children_folders(&self, children: &[ChildIDRef<'_>]) -> bool { ... } fn get_path_of(&self, pidl: ChildIDRef<'_>) -> Result<BSTR> { ... }
}
Expand description

Required Methods§

Source

fn parse_display_name( &self, hwnd: HWND, display_name: PCWSTR, ) -> Result<(usize, RelativeIDList)>

Translates the display name of a file object or a folder into an item identifier list.

  • Doesn’t handle relative path or parent folder indicators (“.” or “..”).
  • Case-insensitive.

IShellFolder::ParseDisplayName (shobjidl_core.h)

§Returns

When it is no longer needed, it is the responsibility of the caller to free this resource by calling [CoTaskMemFree].

Source

fn compare_ids( &self, param: CompareIDs, pidl1: &RelativeIDList, pidl2: &RelativeIDList, ) -> Result<Ordering>

Source

fn get_attributes_of( &self, children: &[ChildIDRef<'_>], mask: ItemAttributes, ) -> Result<ItemAttributes>

IShellFolder::GetAttributesOf (shobjidl_core.h)

§Returns

Requested attributes in mask that are common to all of the specified items.

Source

fn get_display_name_of( &self, pidl: ChildIDRef<'_>, uflags: SHGDNF, ) -> Result<BSTR>

Retrieves the display name for a specified item in the namespace.

IShellFolder::GetDisplayNameOf (shobjidl_core.h)

§Parameters
  • pidl: Pointer to an item identifier list that identifies the child item.

  • uflags: Flags that specify the type of display name to return.

    See _SHGDNF (shobjidl_core.h)

§Returns

The display name of the item specified by pidl, in the format specified by uflags.

Because [STRRET] is hard to work with, this method converts it to BSTR before returning. However, this introduces a mem alloc. If you want to avoid it you can directly call [IShellFolder::GetDisplayNameOf()].

Provided Methods§

Source

fn from_desktop() -> Result<IShellFolder>

Retrieves the [IShellFolder] interface for the desktop folder, which is the root of the Shell’s namespace.

SHGetDesktopFolder (shlobj_core.h)

Source

fn from_id_list(pidl: &RelativeIDList) -> Result<IShellFolder>

Creates a child folder that represents the folder containing the given item.

IShellFolder::BindToObject (shobjidl_core.h)

Source

fn from_path_w(hwnd: HWND, path: PCWSTR) -> Result<IShellFolder>

Creates a shell folder from a display name path.

This combines ShellFolder::parse_display_name() and ShellFolder::from_id_list to parse a path and return its folder.

Ref:

Source

fn from_fs_any(hwnd: HWND) -> Result<IShellFolder>

Returns an arbitrary object of CFSFolder.

Source

fn parse_display_name_to_id_list( &self, hwnd: HWND, display_name: PCWSTR, ) -> Result<RelativeIDList>

Source

fn is_child_folder(&self, child: ChildIDRef<'_>) -> bool

Tests if the child is a Shell folder (not necessarily a file system directory).

This can also be implemented via ShellFolder::get_display_name_of(). But it’s probably slower as attributes are already stored in the ID.

Source

fn is_child_fs_folder(&self, child: ChildIDRef<'_>) -> bool

Tests if the child is a file system directory.

This can also be implemented via ShellFolder::get_path_of(). But it’s probably slower as attributes are already stored in the ID.

Source

fn are_children_folders(&self, children: &[ChildIDRef<'_>]) -> bool

👎Deprecated:

This is usually not supported, including CFSFolder from Windows XP to 11

Tests if the children are Shell folders (not necessarily file system directories).

This can also be implemented via ShellFolder::get_display_name_of(). But it’s probably slower as attributes are already stored in the ID.

Source

fn get_path_of(&self, pidl: ChildIDRef<'_>) -> Result<BSTR>

Get the display name for parsing relative to the desktop.

i.e. get_display_name_of(SHGDN_FORPARSING)

§Returns

e.g. C:\Windows

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ShellFolder for IShellFolder

Source§

fn parse_display_name( &self, hwnd: HWND, display_name: PCWSTR, ) -> Result<(usize, RelativeIDList)>

Source§

fn compare_ids( &self, param: CompareIDs, pidl1: &RelativeIDList, pidl2: &RelativeIDList, ) -> Result<Ordering>

Source§

fn get_attributes_of( &self, children: &[ChildIDRef<'_>], mask: ItemAttributes, ) -> Result<ItemAttributes>

Source§

fn get_display_name_of( &self, pidl: ChildIDRef<'_>, uflags: SHGDNF, ) -> Result<BSTR>

Implementors§