diff --git a/src/modules/previewpane/README.md b/src/modules/previewpane/README.md index 418204ebf..a1220b839 100644 --- a/src/modules/previewpane/README.md +++ b/src/modules/previewpane/README.md @@ -102,11 +102,95 @@ FileExplorerPreviewSettings( L"<--A display name for your preview handler-->") ``` -## Install With MSIX +## Installation + +### MSI + +To add a new Previewer update the `Product.wxs` file in `PowerToysSetup` similar to existing Previewer to register the Preview Handler. More details about registration of Preview Handlers can be [found here.](https://docs.microsoft.com/en-us/windows/win32/shell/how-to-register-a-preview-handler) -<---To Do---> ```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` +### MSIX + +Warning: There are known issues([Issue - 1446](https://github.com/microsoft/PowerToys/issues/1446), [Issue - 1545](https://github.com/microsoft/PowerToys/issues/1545)) with MSIX Installation of Preview Handlers and it's not fully supported. + +To add a new Previewer with MSIX update the `appxmanifest.xml` file to add file type association for preview handler and add `SurrogateServer` element with class registration. MSIX currently doesn't support .Net Assembly activation with `SurrogateServer` the logic used is shim the activation by using native dll. `dllmain.cpp` in `powerpreview` project expose the `DLLGetClassObject` method which is used to activate .net Assembly by using `CoGetClassObject`. + +Changes required in `appxmanifest.xml`: + +```xml + + + + + + .xyz + + + + + + + + + + + +``` +Update the `PackagingLayout.xml` to include dll's required by the new Preview Handler. + +```xml + + +``` + +Add the actual Clsid of the new preview handler in `CLSID.h` in `powerpreview` project and class registration registry changes in `registry.dat` similar to existing preview handler. To update the `registry.dat` mount the registry hive on a empty key in registry by using `reggedit.exe` and add registry key for class registartion for the new preview handler similar to MSI class registration and existing preview handlers. And export the updated `registry.dat` hive also export the `registry.reg` file for making the contents in `registy.dat` visible in source code. + +```cpp +// CLSID used in manifest file for Preview Handler. +const CLSID CLSID_SHIMActivateXYZPreviewHandler = { valid - guid }; + +// Actual Clsid Guid. +const CLSID CLSID_XYZPreviewHandler = { valid - guid }; + +// Pairs of NativeClsid vs ManagedClsid used for preview handlers. +const std::vector> NativeToManagedClsid({ + { CLSID_SHIMActivateXYZPreviewHandler, CLSID_XYZPreviewHandler } +}); ``` ## Managing Preview Handlers