mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 09:49:07 +00:00
First commit CLSIDViewer #1610
This commit is contained in:
@@ -68,7 +68,7 @@ void HelperMethods::ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer)
|
||||
}
|
||||
|
||||
// If CF_HDROP fails, try CFSTR_SHELLIDLIST
|
||||
// Support Desktop Icon (This PC, Recycle Bin and so on)
|
||||
// Support Desktop Icons (This PC, Recycle Bin and so on)
|
||||
// https://github.com/QL-Win/QuickLook/issues/1610
|
||||
static const CLIPFORMAT cfShellIDList = (CLIPFORMAT)RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
|
||||
formatetc.cfFormat = cfShellIDList;
|
||||
|
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="QuickLook.Plugin.CLSIDViewer.CLSIDInfoPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:QuickLook.Plugin.CLSIDViewer"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Height="192"
|
||||
FontSize="14"
|
||||
UseLayoutRounding="True"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<TextBlock x:Name="UnsupportedTextBlock"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed" />
|
||||
<!-- EMPTY -->
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -0,0 +1,44 @@
|
||||
// Copyright © 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace QuickLook.Plugin.CLSIDViewer;
|
||||
|
||||
public partial class CLSIDInfoPanel : UserControl
|
||||
{
|
||||
public CLSIDInfoPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void DisplayInfo(string path)
|
||||
{
|
||||
switch (path.ToUpper())
|
||||
{
|
||||
case "::{645FF040-5081-101B-9F08-00AA002F954E}" // Recycle Bin
|
||||
or "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}": // This PC
|
||||
break;
|
||||
|
||||
default:
|
||||
UnsupportedTextBlock.Text = $"Unsupported for {path}";
|
||||
UnsupportedTextBlock.Visibility = Visibility.Visible;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
// Copyright © 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace QuickLook.Plugin.CLSIDViewer;
|
||||
|
||||
internal static class CLSIDRegister
|
||||
{
|
||||
public static string GetName(string clsid)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Such as `Computer\HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}`
|
||||
string displayName = Registry.GetValue($@"HKEY_CLASSES_ROOT\CLSID\{clsid.Replace(":", string.Empty)}", string.Empty, null)?.ToString();
|
||||
return displayName;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("Error reading registry: " + ex.Message);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
72
QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/Plugin.cs
Normal file
72
QuickLook.Plugin/QuickLook.Plugin.CLSIDViewer/Plugin.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright © 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
using QuickLook.Common.Plugin;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
|
||||
namespace QuickLook.Plugin.CLSIDViewer;
|
||||
|
||||
public class Plugin : IViewer
|
||||
{
|
||||
private CLSIDInfoPanel _ip;
|
||||
private string _path;
|
||||
|
||||
public int Priority => -1;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public bool CanHandle(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
return false;
|
||||
|
||||
// Use Regex to check whether a string like "::{645FF040-5081-101B-9F08-00AA002F954E}"
|
||||
bool isCLSID = path.StartsWith("::")
|
||||
&& Regex.IsMatch(path, @"^::\{[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}\}$");
|
||||
|
||||
return isCLSID;
|
||||
}
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
context.PreferredSize = new Size { Width = 520, Height = 192 };
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
{
|
||||
_path = path;
|
||||
_ip = new CLSIDInfoPanel();
|
||||
|
||||
_ip.DisplayInfo(_path);
|
||||
_ip.Tag = context;
|
||||
|
||||
context.ViewerContent = _ip;
|
||||
context.Title = $"{CLSIDRegister.GetName(path)}";
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
_ip = null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
// Copyright © 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("QuickLook.Plugin.CLSIDViewer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("pooi.moe")]
|
||||
[assembly: AssemblyProduct("QuickLook.Plugin.CLSIDViewer")]
|
||||
[assembly: AssemblyCopyright("Copyright © QL-Win Contributors")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("538fd6ba-2af1-4dda-93a2-6c0a12b00843")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
@@ -0,0 +1,74 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net462</TargetFramework>
|
||||
<RootNamespace>QuickLook.Plugin.CLSIDViewer</RootNamespace>
|
||||
<AssemblyName>QuickLook.Plugin.CLSIDViewer</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<UseWPF>true</UseWPF>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<ProjectGuid>{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.CLSIDViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.CLSIDViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.CLSIDViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.CLSIDViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\QuickLook.Common\QuickLook.Common.csproj">
|
||||
<Project>{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}</Project>
|
||||
<Name>QuickLook.Common</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GitVersion.cs">
|
||||
<Link>Properties\GitVersion.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Translations.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -26,7 +26,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("pooi.moe")]
|
||||
[assembly: AssemblyProduct("QuickLook.Plugin.PEViewer")]
|
||||
[assembly: AssemblyCopyright("Copyright © ema 2024")]
|
||||
[assembly: AssemblyCopyright("Copyright © QL-Win Contributors")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
@@ -51,6 +51,7 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "QuickLook.Installer", "Quic
|
||||
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA} = {BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}
|
||||
{8D50A1DA-601C-4C26-9A7E-7D477EA8430A} = {8D50A1DA-601C-4C26-9A7E-7D477EA8430A}
|
||||
{CE40160D-5E3C-4A41-9BDA-C4F414C174EB} = {CE40160D-5E3C-4A41-9BDA-C4F414C174EB}
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843} = {538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QuickLook.Native64", "QuickLook.Native\QuickLook.Native64\QuickLook.Native64.vcxproj", "{794E4DCF-F715-4836-9D30-ABD296586D23}"
|
||||
@@ -77,6 +78,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.PEViewer",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.FontViewer", "QuickLook.Plugin\QuickLook.Plugin.FontViewer\QuickLook.Plugin.FontViewer.csproj", "{CE40160D-5E3C-4A41-9BDA-C4F414C174EB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.CLSIDViewer", "QuickLook.Plugin\QuickLook.Plugin.CLSIDViewer\QuickLook.Plugin.CLSIDViewer.csproj", "{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -223,6 +226,14 @@ Global
|
||||
{CE40160D-5E3C-4A41-9BDA-C4F414C174EB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CE40160D-5E3C-4A41-9BDA-C4F414C174EB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{CE40160D-5E3C-4A41-9BDA-C4F414C174EB}.Release|x86.Build.0 = Release|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -243,6 +254,7 @@ Global
|
||||
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||
{8D50A1DA-601C-4C26-9A7E-7D477EA8430A} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||
{CE40160D-5E3C-4A41-9BDA-C4F414C174EB} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||
{538FD6BA-2AF1-4DDA-93A2-6C0A12B00843} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D3761C32-8C5F-498A-892B-3B0882994B62}
|
||||
|
@@ -102,10 +102,11 @@ internal static class QuickLook
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
thread.Join();
|
||||
if (sb.Length > 2 && sb[0].Equals('"') && sb[sb.Length - 1].Equals('"'))
|
||||
if (sb.Length > 2 && sb[0] == '"' && sb[sb.Length - 1] == '"')
|
||||
{
|
||||
// We got a quoted string which breaks ResolveShortcut
|
||||
sb = sb.Replace("\"", string.Empty, 0, 1).Replace("\"", string.Empty, sb.Length - 1, 1);
|
||||
sb.Remove(sb.Length - 1, 1); // remove last "
|
||||
sb.Remove(0, 1); // remove first "
|
||||
}
|
||||
return ResolveShortcut(sb?.ToString() ?? string.Empty);
|
||||
}
|
||||
|
@@ -170,6 +170,6 @@ internal class PipeServerManager : IDisposable
|
||||
|
||||
public static PipeServerManager GetInstance()
|
||||
{
|
||||
return _instance ?? (_instance = new PipeServerManager());
|
||||
return _instance ??= new PipeServerManager();
|
||||
}
|
||||
}
|
||||
|
@@ -129,6 +129,7 @@ internal class ViewWindowManager : IDisposable
|
||||
return;
|
||||
|
||||
if (!Directory.Exists(path) && !File.Exists(path))
|
||||
if (!path.StartsWith("::")) // CLSID
|
||||
return;
|
||||
|
||||
_invokedPath = path;
|
||||
@@ -197,7 +198,7 @@ internal class ViewWindowManager : IDisposable
|
||||
{
|
||||
if (ProcessHelper.IsShuttingDown())
|
||||
return;
|
||||
if (!(sender is ViewerWindow w) || w.Pinned)
|
||||
if (sender is not ViewerWindow w || w.Pinned)
|
||||
return; // Pinned window has already been forgotten
|
||||
StopFocusMonitor();
|
||||
InitNewViewerWindow();
|
||||
@@ -206,6 +207,6 @@ internal class ViewWindowManager : IDisposable
|
||||
|
||||
internal static ViewWindowManager GetInstance()
|
||||
{
|
||||
return _instance ?? (_instance = new ViewWindowManager());
|
||||
return _instance ??= new ViewWindowManager();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user