Skip to content

Commit aedec7f

Browse files
authored
Fixed an issue where the 'Empty Recycle Bin' context menu was always grayed out (#2191)
1 parent bd87cc5 commit aedec7f

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

Files.Launcher/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,9 @@ private static async Task parseRecycleBinAction(AppServiceRequestReceivedEventAr
492492

493493
case "Query":
494494
var responseQuery = new ValueSet();
495-
Shell32.SHQUERYRBINFO queryBinInfo = new Shell32.SHQUERYRBINFO();
496-
queryBinInfo.cbSize = (uint)Marshal.SizeOf(queryBinInfo);
497-
var res = Shell32.SHQueryRecycleBin("", ref queryBinInfo);
495+
Win32API.SHQUERYRBINFO queryBinInfo = new Win32API.SHQUERYRBINFO();
496+
queryBinInfo.cbSize = Marshal.SizeOf(queryBinInfo);
497+
var res = Win32API.SHQueryRecycleBin("", ref queryBinInfo);
498498
if (res == HRESULT.S_OK)
499499
{
500500
var numItems = queryBinInfo.i64NumItems;

Files.Launcher/Win32API.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,22 @@ public static (string icon, bool isCustom) GetFileOverlayIcon(string path)
133133
byte[] bitmapData = (byte[])new ImageConverter().ConvertTo(image, typeof(byte[]));
134134
return (Convert.ToBase64String(bitmapData, 0, bitmapData.Length), isCustom);
135135
}
136-
}
137136

138-
// There is usually no need to define Win32 COM interfaces/P-Invoke methods here.
139-
// The Vanara library contains the definitions for all members of Shell32.dll, User32.dll and more
140-
// The ones below are due to bugs in the current version of the library and can be removed once fixed
137+
// There is usually no need to define Win32 COM interfaces/P-Invoke methods here.
138+
// The Vanara library contains the definitions for all members of Shell32.dll, User32.dll and more
139+
// The ones below are due to bugs in the current version of the library and can be removed once fixed
140+
// Structure used by SHQueryRecycleBin.
141+
[StructLayout(LayoutKind.Sequential, Pack = 0)]
142+
public struct SHQUERYRBINFO
143+
{
144+
public int cbSize;
145+
public long i64Size;
146+
public long i64NumItems;
147+
}
148+
149+
// Get information from recycle bin.
150+
[DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)]
151+
public static extern int SHQueryRecycleBin(string pszRootPath,
152+
ref SHQUERYRBINFO pSHQueryRBInfo);
153+
}
141154
}

Files.Launcher/Win32API_ContextMenu.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,4 @@ public void Dispose()
455455
}
456456
}
457457
}
458-
459-
// There is usually no need to define Win32 COM interfaces/P-Invoke methods here.
460-
// The Vanara library contains the definitions for all members of Shell32.dll, User32.dll and more
461-
// The ones below are due to bugs in the current version of the library and can be removed once fixed
462458
}

0 commit comments

Comments
 (0)