Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Runs the automated tests. The build workflow only compiles the application, so the tests live in
# their own project (tests/QuickLook.Tests) and are executed here.

name: tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Run tests
run: dotnet test tests/QuickLook.Tests/QuickLook.Tests.csproj -c Release --logger "console;verbosity=normal"
7 changes: 7 additions & 0 deletions OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ These keys are also stored in `QuickLook.config`.
- Example:
- `<AlwaysUnblockProtectedView>True</AlwaysUnblockProtectedView>`

### `<FixPreviewHandlerRegistration>`
- Default: `True`
- Type: `Boolean`
- Description: When `True`, a preview handler that is only registered in the 32-bit registry view (for example by WPS Office, which is a 32-bit application) is mirrored into the 64-bit registry view for the current user, so that QuickLook can resolve and activate it. Only out-of-process handlers registered through `LocalServer32` are mirrored; a 32-bit in-process handler (`InprocServer32`) cannot be loaded by a 64-bit process and is left untouched. Only `HKEY_CURRENT_USER\Software\Classes\CLSID` is written, no elevation is required, mirrored values are refreshed when the source registration changes, and deleting the mirrored keys reverts the change.
- Example:
- `<FixPreviewHandlerRegistration>False</FixPreviewHandlerRegistration>`

## QuickLook.Plugin.MarkdownViewer.config options

### `<ToggleTocKey>`
Expand Down
66 changes: 37 additions & 29 deletions QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017-2026 QL-Win Contributors
// Copyright © 2017-2026 QL-Win Contributors
//
// This file is part of QuickLook program.
//
Expand Down Expand Up @@ -56,45 +56,53 @@ public bool CanHandle(string path)
if (previewHandler == Guid.Empty)
return false;

// Office suites such as WPS Office are 32-bit applications and register their preview
// handlers only in the 32-bit registry view. QuickLook is a 64-bit process and cannot
// use such a registration, so mirror it into the 64-bit registry view for the current
// user. An existing mirror is refreshed when the source registration changes, therefore
// this must run before the plain registration check below. It also runs when
// CheckPreviewHandler is disabled: that setting skips the availability check, it does not
// opt out of making an otherwise unusable handler work. See also:
// PreviewHandlerRegistration.
var fixPreviewHandlerRegistration = SettingHelper.Get("FixPreviewHandlerRegistration", true, "QuickLook.Plugin.OfficeViewer");
if (fixPreviewHandlerRegistration && PreviewHandlerRegistration.EnsureRegisteredForCurrentView(previewHandler))
return true;

var checkPreviewHandler = SettingHelper.Get("CheckPreviewHandler", true, "QuickLook.Plugin.OfficeViewer");
if (!checkPreviewHandler)
return true;

if (!string.IsNullOrWhiteSpace(CLSIDRegister.GetName(previewHandler.ToString("B"))))
{
if (PreviewHandlerRegistration.IsRegisteredForCurrentView(previewHandler))
return true;
}
else
{
// Legacy: No more recovering registries for MS Office.
// TODO: Add a setting page to let users choose the fallback preview handler if the current one is not working.

// Legacy: No more recovering registries for MS Office.
// TODO: Add a setting page to let users choose the fallback preview handler if the current one is not working.
#if false
// To restore the preview handler CLSID to MS Office
// if running with administrative privileges
if (ShellExRegister.IsRunAsAdmin())
// To restore the preview handler CLSID to MS Office
// if running with administrative privileges
if (ShellExRegister.IsRunAsAdmin())
{
var fileExtension = Path.GetExtension(path);
var fallbackHandler = fileExtension switch
{
var fileExtension = Path.GetExtension(path);
var fallbackHandler = fileExtension switch
{
".doc" or ".docx" or ".docm" or ".odt" => CLSIDRegister.MicrosoftWord,
".xls" or ".xlsx" or ".xlsm" or ".xlsb" or ".ods" => CLSIDRegister.MicrosoftExcel,
".ppt" or ".pptx" or ".odp" => CLSIDRegister.MicrosoftPowerPoint,
".vsd" or ".vsdx" => CLSIDRegister.MicrosoftVisio,
_ => null,
};
".doc" or ".docx" or ".docm" or ".odt" => CLSIDRegister.MicrosoftWord,
".xls" or ".xlsx" or ".xlsm" or ".xlsb" or ".ods" => CLSIDRegister.MicrosoftExcel,
".ppt" or ".pptx" or ".odp" => CLSIDRegister.MicrosoftPowerPoint,
".vsd" or ".vsdx" => CLSIDRegister.MicrosoftVisio,
_ => null,
};

if (fallbackHandler == null)
return false;
if (fallbackHandler == null)
return false;

if (!string.IsNullOrWhiteSpace(CLSIDRegister.GetName(fallbackHandler)))
{
// Admin requested
ShellExRegister.SetPreviewHandlerGUID(fileExtension, new Guid(fallbackHandler));
return true;
}
if (!string.IsNullOrWhiteSpace(CLSIDRegister.GetName(fallbackHandler)))
{
// Admin requested
ShellExRegister.SetPreviewHandlerGUID(fileExtension, new Guid(fallbackHandler));
return true;
}
#endif
}
#endif

return false;
}
Expand Down
Loading