private void HandleDesktopFolder(string parsingName) { // The Desktop can only be acquired via SHGetDesktopFolder*. If our parsing name matches the desktop directory, use this logic. // *This isn't true on Windows 10, but we should use this logic anyway to provide consistency with SHCreateDesktop behavior. if (_userDesktopPath == null) { SetUserDesktopPath(); } if (!string.IsNullOrEmpty(_userDesktopPath) && parsingName.ToLower() == _userDesktopPath) { IsDesktop = true; // Dispose of things that may have been created as part of the ShellItem constructor if (_shellItem != null) { Marshal.FinalReleaseComObject(_shellItem); _shellItem = null; } // Set properties based on SHGetDesktopFolder _shellFolder = GetShellFolder(); Interop.SHGetIDListFromObject(_shellFolder, out _absolutePidl); Interop.SHCreateItemFromIDList(_absolutePidl, typeof(IShellItem).GUID, out _shellItem); } }
private IShellItemImageFactory GetImageFactory(IntPtr absolutePidl) { if (_shellItem == null) { return(null); } try { Interop.SHCreateItemFromIDList(absolutePidl, typeof(IShellItemImageFactory).GUID, out IShellItemImageFactory ppv); return(ppv); } catch (Exception e) { ShellLogger.Error($"ShellItem: Unable to get shell item image factory for {absolutePidl}: {e.Message}"); return(null); } }