ib_shell_item/item/
item2.rs1use windows::{
2 Win32::UI::Shell::{
3 Common::ITEMIDLIST,
4 PropertiesSystem::{GETPROPERTYSTOREFLAGS, IPropertyStore},
5 SHCreateItemFromIDList, SHCreateItemFromParsingName,
6 },
7 core::{PCWSTR, Result},
8};
9
10pub use windows::Win32::UI::Shell::IShellItem2;
11
12pub trait ShellItem2 {
13 fn from_path_w(path: PCWSTR) -> Result<IShellItem2>;
17
18 #[doc(alias = "from_pidl")]
20 fn from_id_list(id_list: *const ITEMIDLIST) -> Result<IShellItem2>;
21
22 fn get_property_store(&self, flags: GETPROPERTYSTOREFLAGS) -> Result<IPropertyStore>;
24}
25
26impl ShellItem2 for IShellItem2 {
27 fn from_path_w(path: PCWSTR) -> Result<IShellItem2> {
28 unsafe { SHCreateItemFromParsingName::<_, _, IShellItem2>(path, None) }
29 }
30
31 fn from_id_list(id_list: *const ITEMIDLIST) -> Result<IShellItem2> {
32 unsafe { SHCreateItemFromIDList::<IShellItem2>(id_list) }
33 }
34
35 fn get_property_store(&self, flags: GETPROPERTYSTOREFLAGS) -> Result<IPropertyStore> {
36 unsafe { self.GetPropertyStore(flags) }
37 }
38}