2024-09-19 09:12:24 -07:00
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets= "Build" xmlns= "http://schemas.microsoft.com/developer/msbuild/2003" >
<Import Project= "..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition= "Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
<Target Name= "GenerateResourceFiles" BeforeTargets= "PrepareForBuild" >
<Exec Command= "powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h new.base.rc new.rc" />
</Target>
<PropertyGroup Label= "Globals" >
<VCProjectVersion > 17.0</VCProjectVersion>
<Keyword > Win32Proj</Keyword>
<ProjectGuid > {8acb33d9-c95b-47d4-8363-9731ee0930a0}</ProjectGuid>
<RootNamespace > NewPlusShellExtension</RootNamespace>
<WindowsTargetPlatformVersion > 10.0.20348.0</WindowsTargetPlatformVersion>
<ProjectName > NewPlus.ShellExtension</ProjectName>
</PropertyGroup>
<Import Project= "$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition= "'$(Configuration)'=='Debug'" Label= "Configuration" >
<ConfigurationType > DynamicLibrary</ConfigurationType>
<UseDebugLibraries > true</UseDebugLibraries>
<PlatformToolset > v143</PlatformToolset>
<CharacterSet > Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition= "'$(Configuration)'=='Release'" Label= "Configuration" >
<ConfigurationType > DynamicLibrary</ConfigurationType>
<UseDebugLibraries > false</UseDebugLibraries>
<PlatformToolset > v143</PlatformToolset>
<WholeProgramOptimization > true</WholeProgramOptimization>
<CharacterSet > Unicode</CharacterSet>
</PropertyGroup>
<Import Project= "$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label= "ExtensionSettings" >
</ImportGroup>
<ImportGroup Label= "Shared" >
</ImportGroup>
<ImportGroup Label= "PropertySheets" >
<Import Project= "$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition= "exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label= "LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label= "UserMacros" />
<PropertyGroup Condition= "'$(Configuration)'=='Debug'" >
<TargetExt > .dll</TargetExt>
<OutDir > ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutDir>
<TargetName > PowerToys.NewPlus.ShellExtension</TargetName>
<IntDir > $(SolutionDir)$(Platform)\$(Configuration)\TemporaryBuild\obj\$(ProjectName)\</IntDir>
<LinkIncremental />
<IgnoreImportLibrary />
</PropertyGroup>
<PropertyGroup Condition= "'$(Configuration)'=='Release'" >
<OutDir > ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutDir>
<TargetName > PowerToys.NewPlus.ShellExtension</TargetName>
<IntDir > $(SolutionDir)$(Platform)\$(Configuration)\TemporaryBuild\obj\$(ProjectName)\</IntDir>
<LinkIncremental />
<IgnoreImportLibrary />
</PropertyGroup>
<ItemDefinitionGroup Condition= "'$(Configuration)'=='Debug'" >
<ClCompile >
<WarningLevel > Level3</WarningLevel>
<SDLCheck > true</SDLCheck>
<PreprocessorDefinitions > WIN32;_DEBUG;NEWPLUSCONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode > true</ConformanceMode>
<PrecompiledHeader > Use</PrecompiledHeader>
<PrecompiledHeaderFile > pch.h</PrecompiledHeaderFile>
<LanguageStandard > stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories > ..\..\..\common\Telemetry;..\..\;..\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link >
<SubSystem > Windows</SubSystem>
<GenerateDebugInformation > true</GenerateDebugInformation>
<EnableUAC > false</EnableUAC>
<ModuleDefinitionFile > dll.def</ModuleDefinitionFile>
<AdditionalDependencies > runtimeobject.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
2025-11-12 10:39:21 +08:00
<IgnoreSpecificDefaultLibraries >
</IgnoreSpecificDefaultLibraries>
2024-09-19 09:12:24 -07:00
</Link>
<PreBuildEvent >
<Command > del $(OutDir)\NewPlusPackage.msix /q
MakeAppx.exe pack /d . /p $(OutDir)NewPlusPackage.msix /nv</Command>
</PreBuildEvent>
<PostBuildEvent >
<Command >
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition= "'$(Configuration)'=='Release'" >
<ClCompile >
<WarningLevel > Level3</WarningLevel>
<FunctionLevelLinking > true</FunctionLevelLinking>
<IntrinsicFunctions > true</IntrinsicFunctions>
<SDLCheck > true</SDLCheck>
<PreprocessorDefinitions > WIN32;NDEBUG;NEWPLUSCONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode > true</ConformanceMode>
<PrecompiledHeader > Use</PrecompiledHeader>
<PrecompiledHeaderFile > pch.h</PrecompiledHeaderFile>
<LanguageStandard > stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories > ..\..\..\common\Telemetry;..\..\;..\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link >
<SubSystem > Windows</SubSystem>
<EnableCOMDATFolding > true</EnableCOMDATFolding>
<OptimizeReferences > true</OptimizeReferences>
<GenerateDebugInformation > true</GenerateDebugInformation>
<EnableUAC > false</EnableUAC>
<ModuleDefinitionFile > dll.def</ModuleDefinitionFile>
<AdditionalDependencies > runtimeobject.lib;$(CoreLibraryDependencies)</AdditionalDependencies>
2025-11-12 10:39:21 +08:00
<IgnoreSpecificDefaultLibraries >
</IgnoreSpecificDefaultLibraries>
2024-09-19 09:12:24 -07:00
</Link>
<PreBuildEvent >
<Command > del $(OutDir)\NewPlusPackage.msix /q
MakeAppx.exe pack /d . /p $(OutDir)NewPlusPackage.msix /nv</Command>
</PreBuildEvent>
<PostBuildEvent >
<Command >
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup >
<ClInclude Include= "dll_main.h" />
2025-11-04 09:27:16 +08:00
<ClInclude Include= "Helpers.h" />
2025-03-18 04:52:51 -07:00
<ClInclude Include= "helpers_filesystem.h" />
<ClInclude Include= "helpers_variables.h" />
2024-09-19 09:12:24 -07:00
<ClInclude Include= "shell_context_menu.h" />
<ClInclude Include= "shell_context_sub_menu.h" />
<ClInclude Include= "shell_context_sub_menu_item.h" />
<ClInclude Include= "constants.h" />
<ClInclude Include= "settings.h" />
<ClInclude Include= "trace.h" />
<ClInclude Include= "new_utilities.h" />
refactor: Replace WiX-based registration with conditional runtime registration for Win10 context menu modules (#41275)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
## Root Cause
WiX-based registration creates persistent Shell Extension entries that:
1. Load DLLs even when the module is disabled
2. Cause cross-OS version conflicts (Win11 loading Win10 extensions)
## Changes Made
1. Removed static Shell Extension registration from PowerToys installer
2. Modified modules to register Shell Extensions during Runner startup
### Modified Modules:
- **PowerRename** (`src/modules/powerrename/dll/dllmain.cpp`)
- **NewPlus**
(`src/modules/NewPlus/NewShellExtensionContextMenu/powertoys_module.cpp`)
- **ImageResizer** (`src/modules/imageresizer/dll/dllmain.cpp`)
- **FileLocksmith**
(`src/modules/FileLocksmith/FileLocksmithExt/PowerToysModule.cpp`)
## Known Migration Issue
**Machine-level installer registry residue**: win10 with machine-level
installers may have residual Shell Extension registry entries that
persist with this change.
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Closes: #40036
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
## AI Summary
This pull request refactors how shell extension registry keys are
managed during installation and uninstallation for several PowerToys
modules. The main change is moving registry key cleanup logic for
context menu shell extensions (ImageResizer, FileLocksmith, PowerRename,
NewPlus) from static installer definitions to new custom uninstall
actions, ensuring more reliable removal and future extensibility.
**Installer and Uninstall Refactoring**
* Added new custom actions (`CleanImageResizerRuntimeRegistryCA`,
`CleanFileLocksmithRuntimeRegistryCA`,
`CleanPowerRenameRuntimeRegistryCA`, `CleanNewPlusRuntimeRegistryCA`) to
programmatically clean up registry keys for each shell extension during
uninstall, implemented in `CustomAction.cpp` and exported in
`CustomAction.def`.
[[1]](diffhunk://#diff-c502a81cdf8afa7a38f0f462709abcdbdfcc44beaa6227a1e64a26566c7e8876R1156-R1262)
[[2]](diffhunk://#diff-f941d599be5fe41667eda00338af694c0f2e65709d497a66487402f13e408200R31-R34)
* Registered these custom actions in `Product.wxs` and ensured they run
before file removal during uninstall.
[[1]](diffhunk://#diff-668b4388b55bb934d7ceccbfdd172f69257c9c607ca19cb9752d4a4940b69886R179-R190)
[[2]](diffhunk://#diff-668b4388b55bb934d7ceccbfdd172f69257c9c607ca19cb9752d4a4940b69886R454-R482)
**Removal of Static Registry Key Definitions**
* Removed static registry key and component definitions for context menu
shell extensions from their respective installer `.wxs` files
(`FileLocksmith.wxs`, `ImageResizer.wxs`, `PowerRename.wxs`,
`NewPlus.wxs`), relying on custom actions for cleanup instead.
[[1]](diffhunk://#diff-7cf9797f8cb6609049763b3b830f6c4a7a02ba5705eb090f7e06fb9c270ca74fL17-L31)
[[2]](diffhunk://#diff-7cf9797f8cb6609049763b3b830f6c4a7a02ba5705eb090f7e06fb9c270ca74fL41)
[[3]](diffhunk://#diff-c6d00805ce9de0eb3f4d42874dccac17be62f36c35d57e8f863b928b5f955d3aL19-L83)
[[4]](diffhunk://#diff-c6d00805ce9de0eb3f4d42874dccac17be62f36c35d57e8f863b928b5f955d3aL93)
[[5]](diffhunk://#diff-d0d69eff3f2d7982679465972b7d3c46dd8006314fb28f0e3a2371e2d5ccedb0L21-L33)
[[6]](diffhunk://#diff-d0d69eff3f2d7982679465972b7d3c46dd8006314fb28f0e3a2371e2d5ccedb0L43)
[[7]](diffhunk://#diff-4fd109f66b896577cad2860a829617ca902b33551afaaa8840372035ade2d3f3L17-L32)
[[8]](diffhunk://#diff-4fd109f66b896577cad2860a829617ca902b33551afaaa8840372035ade2d3f3L42)
**Project File Update**
* Added `shell_ext_registration.h` to the solution file, possibly for
future shell extension registration logic.
These changes improve uninstall reliability and centralize registry
cleanup logic, making future maintenance and extension of shell
extension registration much simpler.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-21 18:10:30 +08:00
<ClInclude Include= "RuntimeRegistration.h" />
2024-09-19 09:12:24 -07:00
<ClInclude Include= "resource.base.h" />
<ClInclude Include= "template_folder.h" />
<ClInclude Include= "pch.h" />
<ClInclude Include= "Generated Files/resource.h" />
<ClInclude Include= "template_item.h" />
</ItemGroup>
<ItemGroup >
2025-11-04 09:27:16 +08:00
<ClCompile Include= "Helpers.cpp" />
2024-11-27 06:22:05 -08:00
<ClCompile Include= "new_utilities.cpp" />
2024-09-19 09:12:24 -07:00
<ClCompile Include= "shell_context_menu.cpp" />
<ClCompile Include= "shell_context_sub_menu.cpp" />
<ClCompile Include= "shell_context_sub_menu_item.cpp" />
<ClCompile Include= "dll_main.cpp" />
<ClCompile Include= "powertoys_module.cpp" />
<ClCompile Include= "settings.cpp" />
<ClCompile Include= "trace.cpp" />
<ClCompile Include= "template_folder.cpp" />
<ClCompile Include= "pch.cpp" >
<PrecompiledHeader > Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include= "template_item.cpp" />
</ItemGroup>
<ItemGroup >
<None Include= "dll.def" />
<None Include= "packages.config" />
<CopyFileToFolders Include= "TemplateExamples\Any files or folders placed in the template folder are available via New+.txt" >
<DeploymentContent > true</DeploymentContent>
<FileType > Document</FileType>
<DestinationFolders > $(OutDir)\Assets\NewPlus\Templates</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include= "TemplateExamples\Example folder\Example txt file.txt" >
<DeploymentContent > true</DeploymentContent>
<FileType > Document</FileType>
<DestinationFolders > $(OutDir)\Assets\NewPlus\Templates\Example folder</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include= "TemplateExamples\Example folder\Another example txt file.txt" >
<DeploymentContent > true</DeploymentContent>
<FileType > Document</FileType>
<DestinationFolders > $(OutDir)\Assets\NewPlus\Templates\Example folder</DestinationFolders>
</CopyFileToFolders>
</ItemGroup>
<ItemGroup >
<ProjectReference Include= "..\..\..\common\logger\logger.vcxproj" >
<Project > {d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
</ProjectReference>
<ProjectReference Include= "..\..\..\common\SettingsAPI\SettingsAPI.vcxproj" >
<Project > {6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
2024-10-24 22:04:32 +02:00
<ProjectReference Include= "..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj" >
<Project > {8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
</ProjectReference>
2024-09-19 09:12:24 -07:00
<ProjectReference Include= "..\..\..\common\Themes\Themes.vcxproj" >
<Project > {98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>
<ProjectReference Include= "..\..\..\common\version\version.vcxproj" >
<Project > {cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup >
<ResourceCompile Include= "Generated Files/new.rc" />
<None Include= "new.base.rc" />
</ItemGroup>
<ItemGroup >
<None Include= "Assets\NewPlus\LargeTile.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\New_dark.ico" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\New_light.ico" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\Open_templates_dark.ico" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\Open_templates_light.ico" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\SmallTile.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\SplashScreen.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\Square150x150Logo.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\Square44x44Logo.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\StoreLogo.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
<None Include= "Assets\NewPlus\Wide310x150Logo.png" >
<CopyToOutputDirectory > PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup >
<None Include= "resources.resx" >
<SubType > Designer</SubType>
</None>
</ItemGroup>
<ItemGroup >
<None Include= "AppxManifest.xml" />
</ItemGroup>
<Import Project= "$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project= "..\..\..\..\deps\spdlog.props" />
<ImportGroup Label= "ExtensionTargets" >
2024-11-27 06:22:05 -08:00
<Import Project= "..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition= "Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" />
2024-09-19 09:12:24 -07:00
</ImportGroup>
<Target Name= "EnsureNuGetPackageBuildImports" BeforeTargets= "PrepareForBuild" >
<PropertyGroup >
<ErrorText > This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition= "!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" Text= "$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition= "!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text= "$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>