Skip to content

Commit 23ac348

Browse files
committed
Update
1 parent c861720 commit 23ac348

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ PSGetPropertyKeyFromName
135135
ShellExecuteEx
136136
SHAddToRecentDocs
137137
SHARD
138-
IShellLinkW
139-
BHID_SFUIObject
140138
BHID_EnumItems
141-
FOLDERID_Recent
142139
FOLDERID_RecycleBinFolder
143-
SHGetSpecialFolderLocation
144-
IShellUrl
140+
CoTaskMemFree

src/Files.App/Services/Windows/WindowsRecentItemsService.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ private unsafe bool UpdateRecentFilesInternal()
172172
{
173173
HRESULT hr = default;
174174

175-
// TODO: Use IShellUrl to perse all what FE can parse
176175
string szFolderShellPath = "Shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}";
177176
var shellItemIid = typeof(IShellItem).GUID;
178177
using ComPtr<IShellItem> pFolderShellItem = default;
@@ -188,33 +187,30 @@ private unsafe bool UpdateRecentFilesInternal()
188187

189188
// Enumerate recent items and populate the list
190189
int index = 0;
191-
var shellLinkIid = typeof(IShellLinkW).GUID;
192-
var sfUIObjectBHID = PInvoke.BHID_SFUIObject;
193190
using ComPtr<IShellItem> pShellItem = default;
194191
while (pEnumShellItems.Get()->Next(1, pShellItem.GetAddressOf()) == HRESULT.S_OK)
195192
{
196193
// Get top 20 items
197194
if (index is 20)
198195
break;
199196

200-
// Get IShellLink
201-
using ComPtr<IShellLinkW> pShellLink = default;
202-
pShellItem.Get()->BindToHandler(null, &sfUIObjectBHID, &shellLinkIid, (void**)pShellLink.GetAddressOf());
203-
204197
// Get the target path
205198
pShellItem.Get()->GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEEDITING, out var szTargetItemPath);
206199
if (szTargetItemPath.Value == null)
207200
pShellItem.Get()->GetDisplayName(SIGDN.SIGDN_FILESYSPATH, out szTargetItemPath);
208201
var targetPath = szTargetItemPath.ToString();
202+
PInvoke.CoTaskMemFree((void*)szTargetItemPath.Value);
209203

210204
// Get the display name
211-
var szFileName = GetPropertyKey(pShellItem.Get(), "System.ItemNameDisplay");
212-
var fileName = szFileName.ToString();
213-
// TODO: Try also SIGDN_NORMALDISPLAY first and then SIGDN_PARENTRELATIVEPARSING too
205+
var fileName = GetPropertyKey(pShellItem.Get(), "System.ItemNameDisplay");
206+
// TODO: Probably should try also SIGDN_NORMALDISPLAY and then SIGDN_PARENTRELATIVEPARSING too?
214207

215-
// Strip the file extension except when the file name contains only extension (e.g. ".gitignore")
216-
string strippedExtension = SystemIO.Path.GetFileNameWithoutExtension(fileName);
217-
fileName = string.IsNullOrEmpty(strippedExtension) ? SystemIO.Path.GetFileName(fileName) : strippedExtension;
208+
// Strip the file extension except when the file name only contains extension (e.g. ".gitignore")
209+
if (!FoldersSettingsService.ShowFileExtensions)
210+
{
211+
string strippedExtension = SystemIO.Path.GetFileNameWithoutExtension(fileName);
212+
fileName = string.IsNullOrEmpty(strippedExtension) ? SystemIO.Path.GetFileName(fileName) : strippedExtension;
213+
}
218214

219215
recentItems.Add(new()
220216
{

0 commit comments

Comments
 (0)