Windows shell extensions: Add WiX (MSI) fragment
authorMichael Schuster <michael@schuster.ms>
Tue, 18 Aug 2020 19:42:31 +0000 (21:42 +0200)
committerMichael Schuster <michael@schuster.ms>
Thu, 20 Aug 2020 16:50:05 +0000 (18:50 +0200)
Use CMake to generate a WXI fragment to handle the DLL registration and file deployment for the shellext components.

Signed-off-by: Michael Schuster <michael@schuster.ms>
shell_integration/windows/CMakeLists.txt
shell_integration/windows/WinShellExt.wxs.in [new file with mode: 0644]
shell_integration/windows/WinShellExtConstants.h.in
shell_integration/windows/WinShellExtConstants.wxi.in [deleted file]

index a350b09d607c7b76f9af9978a6489b2804e48be7..d75d2574dbee46fac221bd47cb8436217e2c6a8a 100644 (file)
@@ -7,7 +7,7 @@ include_directories(
     ${CMAKE_CURRENT_BINARY_DIR}
 )
 configure_file(WinShellExtConstants.h.in ${CMAKE_CURRENT_BINARY_DIR}/WinShellExtConstants.h)
-configure_file(WinShellExtConstants.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/WinShellExtConstants.wxi)
+configure_file(WinShellExt.wxs.in ${CMAKE_CURRENT_BINARY_DIR}/WinShellExt.wxs)
 
 add_subdirectory(NCContextMenu)
 add_subdirectory(NCOverlays)
diff --git a/shell_integration/windows/WinShellExt.wxs.in b/shell_integration/windows/WinShellExt.wxs.in
new file mode 100644 (file)
index 0000000..6ac42dc
--- /dev/null
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ *
+ * Copyright (C) by Michael Schuster <michael.schuster@nextcloud.com>
+ *
+ * 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 2 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.
+ *
+-->
+<?include $(var.ProjectPath)Platform.wxi?>
+
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+    <Fragment>
+
+        <!--
+            IMPORTANT: Keep these constants in sync with WinShellExtConstants.h.in
+        -->
+
+        <!-- Context Menu -->
+        <?define ContextMenuGuid        = "@WIN_SHELLEXT_CONTEXT_MENU_GUID@" ?>
+        <?define ContextMenuRegKeyName  = "@APPLICATION_SHORTNAME@ContextMenuHandler" ?>
+
+        <?define ContextMenuDescription = "@APPLICATION_SHORTNAME@ context menu handler" ?>
+
+        <!-- Overlays -->
+        <?define OverlayGuidError       = "@WIN_SHELLEXT_OVERLAY_GUID_ERROR@" ?>
+        <?define OverlayGuidOK          = "@WIN_SHELLEXT_OVERLAY_GUID_OK@" ?>
+        <?define OverlayGuidOKShared    = "@WIN_SHELLEXT_OVERLAY_GUID_OK_SHARED@" ?>
+        <?define OverlayGuidSync        = "@WIN_SHELLEXT_OVERLAY_GUID_SYNC@" ?>
+        <?define OverlayGuidWarning     = "@WIN_SHELLEXT_OVERLAY_GUID_WARNING@" ?>
+
+        <!--
+            Preceeding spaces are intended, two spaces to put us ahead of the competition :/
+
+            There is a limit in Windows (oh wonder^^) so that only the first 15 extensions get invoked, this is why to use that dirty little trick to get ahead ;)
+            See: https://docs.microsoft.com/en-us/windows/win32/shell/context-menu-handlers?redirectedfrom=MSDN#employing-the-verb-selection-model
+        -->
+        <?define OverlayNameError       = "  @APPLICATION_SHORTNAME@Error" ?>
+        <?define OverlayNameOK          = "  @APPLICATION_SHORTNAME@OK" ?>
+        <?define OverlayNameOKShared    = "  @APPLICATION_SHORTNAME@OKShared" ?>
+        <?define OverlayNameSync        = "  @APPLICATION_SHORTNAME@Sync" ?>
+        <?define OverlayNameWarning     = "  @APPLICATION_SHORTNAME@Warning" ?>
+
+        <?define OverlayDescription     = "@APPLICATION_SHORTNAME@ overlay handler" ?>
+
+        <!--
+            Integration for Windows Explorer
+
+            Avoid SelfReg by the DLLs, see:
+            https://stackoverflow.com/questions/364187/how-do-you-register-a-win32-com-dll-file-in-wix-3#364210
+            https://docs.microsoft.com/en-us/windows/win32/msi/selfreg-table#remarks
+        -->
+
+        <DirectoryRef Id="ShellExtDir">
+            <Component Id="NCContextMenu" Guid="*" Win64="$(var.PlatformWin64)">
+                <File Id="NCContextMenu.dll" KeyPath="yes" Source="$(var.HarvestAppDir)\shellext\NCContextMenu.dll">
+                    <Class Id="$(var.ContextMenuGuid)" Context="InprocServer32" Description="$(var.ContextMenuDescription)" ThreadingModel="apartment" />
+                </File>
+                <RegistryValue Root="HKCR" Key="AllFileSystemObjects\shellex\ContextMenuHandlers\$(var.ContextMenuRegKeyName)" Value="$(var.ContextMenuGuid)" Type="string" Action="write" />
+            </Component>
+
+            <Component Id="NCOverlays" Guid="*" Win64="$(var.PlatformWin64)">
+                <File Id="NCOverlays.dll" KeyPath="yes" Source="$(var.HarvestAppDir)\shellext\NCOverlays.dll">
+                    <Class Id="$(var.OverlayGuidError)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />
+                    <Class Id="$(var.OverlayGuidOK)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />
+                    <Class Id="$(var.OverlayGuidOKShared)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />
+                    <Class Id="$(var.OverlayGuidSync)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />
+                    <Class Id="$(var.OverlayGuidWarning)" Context="InprocServer32" Description="$(var.OverlayDescription)" ThreadingModel="apartment" Version="1.0" />
+                </File>
+                <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers">
+                    <RegistryValue Key="$(var.OverlayNameError)" Value="$(var.OverlayGuidError)" Type="string" Action="write" />
+                    <RegistryValue Key="$(var.OverlayNameOK)" Value="$(var.OverlayGuidOK)" Type="string" Action="write" />
+                    <RegistryValue Key="$(var.OverlayNameOKShared)" Value="$(var.OverlayGuidOKShared)" Type="string" Action="write" />
+                    <RegistryValue Key="$(var.OverlayNameSync)" Value="$(var.OverlayGuidSync)" Type="string" Action="write" />
+                    <RegistryValue Key="$(var.OverlayNameWarning)" Value="$(var.OverlayGuidWarning)" Type="string" Action="write" />
+                </RegistryKey>
+            </Component>
+        </DirectoryRef>
+
+        <ComponentGroup Id="ShellExtensions">
+            <ComponentRef Id="NCContextMenu" />
+            <ComponentRef Id="NCOverlays" />
+        </ComponentGroup>
+
+    </Fragment>
+</Wix>
index 0303ac174b1cddc4310da156d3714fd6d37d798e..cad7539d200216c6772a6a0a18407dca7f48a112 100644 (file)
@@ -14,7 +14,7 @@
 
 #pragma once
 
-// IMPORTANT: Keep this file in sync with WinShellExtConstants.wxi.in
+// IMPORTANT: Keep these constants in sync with WinShellExtConstants.wxi.in
 
 // Context Menu
 #define CONTEXT_MENU_GUID           L"@WIN_SHELLEXT_CONTEXT_MENU_GUID@"
diff --git a/shell_integration/windows/WinShellExtConstants.wxi.in b/shell_integration/windows/WinShellExtConstants.wxi.in
deleted file mode 100644 (file)
index 9e65fd0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- *
- * Copyright (C) by Michael Schuster <michael.schuster@nextcloud.com>
- *
- * 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 2 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.
- *
--->
-<Include>
-
-    <!--
-        IMPORTANT: Keep this file in sync with WinShellExtConstants.h.in
-    -->
-
-    <!-- Context Menu -->
-    <?define ContextMenuGuid        = "@WIN_SHELLEXT_CONTEXT_MENU_GUID@" ?>
-    <?define ContextMenuRegKeyName  = "@APPLICATION_SHORTNAME@ContextMenuHandler" ?>
-
-    <?define ContextMenuDescription = "@APPLICATION_SHORTNAME@ context menu handler" ?>
-
-    <!-- Overlays -->
-    <?define OverlayGuidError       = "@WIN_SHELLEXT_OVERLAY_GUID_ERROR@" ?>
-    <?define OverlayGuidOK          = "@WIN_SHELLEXT_OVERLAY_GUID_OK@" ?>
-    <?define OverlayGuidOKShared    = "@WIN_SHELLEXT_OVERLAY_GUID_OK_SHARED@" ?>
-    <?define OverlayGuidSync        = "@WIN_SHELLEXT_OVERLAY_GUID_SYNC@" ?>
-    <?define OverlayGuidWarning     = "@WIN_SHELLEXT_OVERLAY_GUID_WARNING@" ?>
-
-    <!--
-        Preceeding spaces are intended, two spaces to put us ahead of the competition :/
-
-        There is a limit in Windows (oh wonder^^) so that only the first 15 extensions get invoked, this is why to use that dirty little trick to get ahead ;)
-        See: https://docs.microsoft.com/en-us/windows/win32/shell/context-menu-handlers?redirectedfrom=MSDN#employing-the-verb-selection-model
-    -->
-    <?define OverlayNameError       = "  @APPLICATION_SHORTNAME@Error" ?>
-    <?define OverlayNameOK          = "  @APPLICATION_SHORTNAME@OK" ?>
-    <?define OverlayNameOKShared    = "  @APPLICATION_SHORTNAME@OKShared" ?>
-    <?define OverlayNameSync        = "  @APPLICATION_SHORTNAME@Sync" ?>
-    <?define OverlayNameWarning     = "  @APPLICATION_SHORTNAME@Warning" ?>
-
-    <?define OverlayDescription     = "@APPLICATION_SHORTNAME@ overlay handler" ?>
-
-</Include>