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 IntPtr GetAbsolutePidl() { IntPtr pidl = IntPtr.Zero; try { if (_shellItem != null) { Interop.SHGetIDListFromObject(_shellItem, out pidl); } } catch (Exception e) { ShellLogger.Error($"ShellItem: Unable to get absolute pidl: {e.Message}"); } return(pidl); }