diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml
index 4507520..e35cf60 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml
@@ -8,11 +8,5 @@
FontSize="14"
UseLayoutRounding="True"
mc:Ignorable="d">
-
-
-
-
+
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml.cs
index 60155e2..05ff0b9 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDInfoPanel.xaml.cs
@@ -24,6 +24,7 @@ public partial class CLSIDInfoPanel : UserControl
{
public CLSIDInfoPanel()
{
+ DataContext = this;
InitializeComponent();
}
@@ -31,13 +32,21 @@ public partial class CLSIDInfoPanel : UserControl
{
switch (path.ToUpper())
{
- case "::{645FF040-5081-101B-9F08-00AA002F954E}" // Recycle Bin
- or "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}": // This PC
+ case CLSIDRegister.RecycleBin:
+ Content = new RecycleBinPanel();
+ break;
+
+ case CLSIDRegister.ThisPC:
+ Content = new ThisPCPanel();
break;
default:
- UnsupportedTextBlock.Text = $"Unsupported for {path}";
- UnsupportedTextBlock.Visibility = Visibility.Visible;
+ Content = new TextBlock()
+ {
+ Text = $"Unsupported for {path}",
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
break;
}
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDRegister.cs b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDRegister.cs
index 0ecf12a..087df31 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDRegister.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/CLSIDRegister.cs
@@ -23,6 +23,9 @@ namespace QuickLook.Plugin.CLSIDViewer;
internal static class CLSIDRegister
{
+ public const string RecycleBin = "::{645FF040-5081-101B-9F08-00AA002F954E}";
+ public const string ThisPC = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
+
public static string GetName(string clsid)
{
try
@@ -31,10 +34,10 @@ internal static class CLSIDRegister
string displayName = Registry.GetValue($@"HKEY_CLASSES_ROOT\CLSID\{clsid.Replace(":", string.Empty)}", string.Empty, null)?.ToString();
return displayName;
}
- catch (Exception ex)
+ catch (Exception e)
{
- Debug.WriteLine("Error reading registry: " + ex.Message);
+ Debug.WriteLine("Error reading registry: " + e.Message);
}
- return string.Empty;
+ return null;
}
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/Plugin.cs
index 79c52fa..eb53f52 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/Plugin.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/Plugin.cs
@@ -47,7 +47,12 @@ public class Plugin : IViewer
public void Prepare(string path, ContextObject context)
{
- context.PreferredSize = new Size { Width = 520, Height = 192 };
+ context.PreferredSize = path switch
+ {
+ CLSIDRegister.RecycleBin => new Size { Width = 520, Height = 192 },
+ CLSIDRegister.ThisPC => new Size { Width = 900, Height = 800 },
+ _ => new Size { Width = 520, Height = 192 },
+ };
}
public void View(string path, ContextObject context)
@@ -59,7 +64,7 @@ public class Plugin : IViewer
_ip.Tag = context;
context.ViewerContent = _ip;
- context.Title = $"{CLSIDRegister.GetName(path)}";
+ context.Title = $"{CLSIDRegister.GetName(path) ?? path}";
context.IsBusy = false;
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/RecycleBinPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/RecycleBinPanel.xaml
new file mode 100644
index 0000000..44d10c3
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/RecycleBinPanel.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/RecycleBinPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/RecycleBinPanel.xaml.cs
new file mode 100644
index 0000000..ff6d675
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/RecycleBinPanel.xaml.cs
@@ -0,0 +1,105 @@
+// Copyright © 2017-2025 QL-Win Contributors
+//
+// This file is part of QuickLook program.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace QuickLook.Plugin.CLSIDViewer;
+
+public partial class RecycleBinPanel : UserControl
+{
+ public RecycleBinPanel()
+ {
+ InitializeComponent();
+ Loaded += OnRecycleBinPanelLoaded;
+ }
+
+ private void OnRecycleBinPanelLoaded(object sender, RoutedEventArgs e)
+ {
+ UpdateState();
+ }
+
+ private void OnEmptyRecycleBinClick(object sender, RoutedEventArgs e)
+ {
+ // TODO: Use async to avoid blocking the UI thread
+ if (RecycleBinHelper.EmptyRecycleBin())
+ {
+ UpdateState();
+ }
+ }
+
+ private void UpdateState()
+ {
+ bool hasTrash = RecycleBinHelper.HasTrash();
+
+ EmptyRecycleBinButton.Visibility = hasTrash ? Visibility.Visible : Visibility.Collapsed;
+ EmptyRecycleBinText.Visibility = hasTrash ? Visibility.Collapsed : Visibility.Visible;
+ }
+}
+
+file static class RecycleBinHelper
+{
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ public struct SHQUERYRBINFO
+ {
+ public uint cbSize;
+ public ulong i64Size;
+ public ulong i64NumItems;
+ }
+
+ [DllImport("shell32.dll", CharSet = CharSet.Unicode)]
+ private static extern int SHQueryRecycleBin(string pszRootPath, ref SHQUERYRBINFO pSHQueryRBInfo);
+
+ [DllImport("shell32.dll", CharSet = CharSet.Unicode)]
+ private static extern int SHEmptyRecycleBin(nint hwnd, string pszRootPath, RecycleFlags dwFlags);
+
+ [Flags]
+ private enum RecycleFlags : uint
+ {
+ SHERB_NOCONFIRMATION = 0x00000001,
+ SHERB_NOPROGRESSUI = 0x00000002,
+ SHERB_NOSOUND = 0x00000004,
+ }
+
+ public static bool HasTrash()
+ {
+ var info = new SHQUERYRBINFO()
+ {
+ cbSize = (uint)Marshal.SizeOf(typeof(SHQUERYRBINFO))
+ };
+
+ int result = SHQueryRecycleBin(null, ref info);
+
+ if (result == 0) // S_OK
+ {
+ return info.i64NumItems > 0;
+ }
+
+ // Fallback
+ return false;
+ }
+
+ public static bool EmptyRecycleBin()
+ {
+ int result = SHEmptyRecycleBin(IntPtr.Zero, null,
+ RecycleFlags.SHERB_NOCONFIRMATION | RecycleFlags.SHERB_NOPROGRESSUI | RecycleFlags.SHERB_NOSOUND);
+
+ return result == 0;
+ }
+}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/ThisPCPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/ThisPCPanel.xaml
new file mode 100644
index 0000000..a6fd4eb
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/ThisPCPanel.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/ThisPCPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/ThisPCPanel.xaml.cs
new file mode 100644
index 0000000..895a290
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/ThisPCPanel.xaml.cs
@@ -0,0 +1,28 @@
+// Copyright © 2017-2025 QL-Win Contributors
+//
+// This file is part of QuickLook program.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System.Windows.Controls;
+
+namespace QuickLook.Plugin.CLSIDViewer;
+
+public partial class ThisPCPanel : UserControl
+{
+ public ThisPCPanel()
+ {
+ InitializeComponent();
+ }
+}