mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-08 01:52:52 +08:00
Runner: move Launcher to its own folder and simplify dll loading (#4379)
This commit is contained in:
parent
bef14f551e
commit
8c6085b933
@ -406,10 +406,6 @@
|
|||||||
|
|
||||||
<DirectoryRef Id="ModulesInstallFolder" FileSource="$(var.BinX64Dir)modules\">
|
<DirectoryRef Id="ModulesInstallFolder" FileSource="$(var.BinX64Dir)modules\">
|
||||||
|
|
||||||
<Component Id="Module_Launcher" Guid="9A343236-B49D-451D-A27D-4C336F460A45" Win64="yes">
|
|
||||||
<File Source="$(var.BinX64Dir)modules\Microsoft.Launcher.dll" />
|
|
||||||
</Component>
|
|
||||||
|
|
||||||
<Component Id="Module_PowerPreview_PerUserRegistry" Guid="CD90ADC0-7CD5-4A62-B0AF-23545C1E6DD3" Win64="yes">
|
<Component Id="Module_PowerPreview_PerUserRegistry" Guid="CD90ADC0-7CD5-4A62-B0AF-23545C1E6DD3" Win64="yes">
|
||||||
<!-- Added a separate component for Per-User registry changes -->
|
<!-- Added a separate component for Per-User registry changes -->
|
||||||
<!-- Registry Key for Class Registration of Svg Preview Handler -->
|
<!-- Registry Key for Class Registration of Svg Preview Handler -->
|
||||||
@ -742,7 +738,6 @@
|
|||||||
<ComponentRef Id="Module_ImageResizer_Registry" />
|
<ComponentRef Id="Module_ImageResizer_Registry" />
|
||||||
<ComponentRef Id="Module_PowerPreview" />
|
<ComponentRef Id="Module_PowerPreview" />
|
||||||
<ComponentRef Id="Module_PowerPreview_PerUserRegistry" />
|
<ComponentRef Id="Module_PowerPreview_PerUserRegistry" />
|
||||||
<ComponentRef Id="Module_Launcher" />
|
|
||||||
<ComponentRef Id="Module_KeyboardManager" />
|
<ComponentRef Id="Module_KeyboardManager" />
|
||||||
<ComponentRef Id="SettingsV2" />
|
<ComponentRef Id="SettingsV2" />
|
||||||
<ComponentRef Id="SettingsV2Assets" />
|
<ComponentRef Id="SettingsV2Assets" />
|
||||||
@ -783,6 +778,7 @@
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<ComponentGroup Id="LauncherComponents">
|
<ComponentGroup Id="LauncherComponents">
|
||||||
<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
|
<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
|
||||||
|
<File Source="$(var.BinX64Dir)modules\Launcher\Microsoft.Launcher.dll" />
|
||||||
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;EntityFramework.SqlServer.dll;EntityFramework.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;Pinyin4Net.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Toolkit.Win32.UI.XamlHost.Managed.dll;Microsoft.Toolkit.Wpf.UI.XamlHost.dll;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;sni.dll;System.Data.SQLite.EF6.dll;PowerLauncher.runtimeconfig.json;SQLite.Interop.dll;System.Data.OleDb.dll;System.Data.SqlClient.dll;System.Data.SQLite.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;WindowsInput.dll;Wox.Core.dll;Wox.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;Telemetry.dll;PowerLauncher.Telemetry.dll;PropertyChanged.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;MahApps.Metro.dll?>
|
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;EntityFramework.SqlServer.dll;EntityFramework.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;Pinyin4Net.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Toolkit.Win32.UI.XamlHost.Managed.dll;Microsoft.Toolkit.Wpf.UI.XamlHost.dll;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;sni.dll;System.Data.SQLite.EF6.dll;PowerLauncher.runtimeconfig.json;SQLite.Interop.dll;System.Data.OleDb.dll;System.Data.SqlClient.dll;System.Data.SQLite.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;WindowsInput.dll;Wox.Core.dll;Wox.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;Telemetry.dll;PowerLauncher.Telemetry.dll;PropertyChanged.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;MahApps.Metro.dll?>
|
||||||
<File Id="File_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\$(var.File)" />
|
<File Id="File_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\$(var.File)" />
|
||||||
<?endforeach?>
|
<?endforeach?>
|
||||||
|
@ -49,11 +49,11 @@
|
|||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\</OutDir>
|
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\launcher</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\</OutDir>
|
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\launcher</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -127,50 +127,29 @@ int runner(bool isProcessElevated)
|
|||||||
notifications::register_background_toast_handler();
|
notifications::register_background_toast_handler();
|
||||||
|
|
||||||
chdir_current_executable();
|
chdir_current_executable();
|
||||||
// Load Powertoys DLLS
|
// Load Powertoys DLLs
|
||||||
// For now only load known DLLs
|
|
||||||
|
|
||||||
std::wstring baseModuleFolder = L"modules/";
|
const std::array<std::wstring_view, 7> knownModules = {
|
||||||
|
L"modules/FancyZones/fancyzones.dll",
|
||||||
std::unordered_set<std::wstring> known_dlls = {
|
L"modules/FileExplorerPreview/powerpreview.dll",
|
||||||
L"ShortcutGuide.dll",
|
L"modules/ImageResizer/ImageResizerExt.dll",
|
||||||
L"fancyzones.dll",
|
L"modules/KeyboardManager/KeyboardManager.dll",
|
||||||
L"PowerRenameExt.dll",
|
L"modules/Launcher/Microsoft.Launcher.dll",
|
||||||
L"Microsoft.Launcher.dll",
|
L"modules/PowerRename/PowerRenameExt.dll",
|
||||||
L"ImageResizerExt.dll",
|
L"modules/ShortcutGuide/ShortcutGuide.dll",
|
||||||
L"powerpreview.dll",
|
|
||||||
L"KeyboardManager.dll"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(stefan): When all modules get their OutputDir delete this and simplify "search for .dll logic"
|
for (const auto & moduleSubdir : knownModules)
|
||||||
std::unordered_set<std::wstring> module_folders = {
|
|
||||||
L"",
|
|
||||||
L"FileExplorerPreview/",
|
|
||||||
L"FancyZones/",
|
|
||||||
L"ImageResizer/",
|
|
||||||
L"PowerRename/",
|
|
||||||
L"ShortcutGuide/",
|
|
||||||
L"KeyboardManager/"
|
|
||||||
};
|
|
||||||
|
|
||||||
for (std::wstring subfolderName : module_folders)
|
|
||||||
{
|
{
|
||||||
for (auto& file : std::filesystem::directory_iterator(baseModuleFolder + subfolderName))
|
|
||||||
{
|
|
||||||
if (file.path().extension() != L".dll")
|
|
||||||
continue;
|
|
||||||
if (known_dlls.find(file.path().filename()) == known_dlls.end())
|
|
||||||
continue;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto module = load_powertoy(file.path().wstring());
|
auto module = load_powertoy(moduleSubdir);
|
||||||
modules().emplace(module->get_name(), std::move(module));
|
modules().emplace(module->get_name(), std::move(module));
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Start initial powertoys
|
// Start initial powertoys
|
||||||
start_initial_powertoys();
|
start_initial_powertoys();
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ std::map<std::wstring, PowertoyModule>& modules()
|
|||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
PowertoyModule load_powertoy(const std::wstring& filename)
|
PowertoyModule load_powertoy(const std::wstring_view filename)
|
||||||
{
|
{
|
||||||
auto handle = winrt::check_pointer(LoadLibraryW(filename.c_str()));
|
auto handle = winrt::check_pointer(LoadLibraryW(filename.data()));
|
||||||
auto create = reinterpret_cast<powertoy_create_func>(GetProcAddress(handle, "powertoy_create"));
|
auto create = reinterpret_cast<powertoy_create_func>(GetProcAddress(handle, "powertoy_create"));
|
||||||
if (!create)
|
if (!create)
|
||||||
{
|
{
|
||||||
|
@ -49,5 +49,5 @@ private:
|
|||||||
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> module;
|
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> module;
|
||||||
};
|
};
|
||||||
|
|
||||||
PowertoyModule load_powertoy(const std::wstring& filename);
|
PowertoyModule load_powertoy(const std::wstring_view filename);
|
||||||
std::map<std::wstring, PowertoyModule>& modules();
|
std::map<std::wstring, PowertoyModule>& modules();
|
||||||
|
Loading…
Reference in New Issue
Block a user