use windows::{
Win32::UI::Shell::{
Common::ITEMIDLIST,
PropertiesSystem::{GETPROPERTYSTOREFLAGS, IPropertyStore},
SHCreateItemFromIDList, SHCreateItemFromParsingName,
},
core::{PCWSTR, Result},
};
pub use windows::Win32::UI::Shell::IShellItem2;
pub trait ShellItem2 {
fn from_path_w(path: PCWSTR) -> Result<IShellItem2>;
#[doc(alias = "from_pidl")]
fn from_id_list(id_list: *const ITEMIDLIST) -> Result<IShellItem2>;
fn get_property_store(&self, flags: GETPROPERTYSTOREFLAGS) -> Result<IPropertyStore>;
}
impl ShellItem2 for IShellItem2 {
fn from_path_w(path: PCWSTR) -> Result<IShellItem2> {
unsafe { SHCreateItemFromParsingName::<_, _, IShellItem2>(path, None) }
}
fn from_id_list(id_list: *const ITEMIDLIST) -> Result<IShellItem2> {
unsafe { SHCreateItemFromIDList::<IShellItem2>(id_list) }
}
fn get_property_store(&self, flags: GETPROPERTYSTOREFLAGS) -> Result<IPropertyStore> {
unsafe { self.GetPropertyStore(flags) }
}
}