forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
powerrename: implement shellext support for UWP
- Loading branch information
Showing
25 changed files
with
511 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
$name='PowerToys' | ||
taskkill /f /im explorer.exe | ||
Get-AppxPackage -Name $name | select -ExpandProperty "PackageFullName" | Remove-AppxPackage | ||
makeappx build /v /overwrite /f PackagingLayout.xml /id "x64" /op bin\ | ||
signtool sign /debug /a /fd SHA256 /f PowerToysTestKey.pfx /p 12345 bin\x64.msix | ||
Add-AppxPackage .\bin\x64.msix | ||
start $Env:windir\explorer.exe |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include "stdafx.h" | ||
|
||
#include "resource.h" | ||
#include <CLSID.h> | ||
#include <PowerRenameExt.h> | ||
#include <common.h> | ||
|
||
std::atomic<DWORD> g_dwModuleRefCount = 0; | ||
|
||
DWORD main_thread_id; | ||
|
||
void ModuleAddRef() | ||
{ | ||
++g_dwModuleRefCount; | ||
} | ||
|
||
void ModuleRelease() | ||
{ | ||
if(--g_dwModuleRefCount == 0) | ||
{ | ||
PostThreadMessage(main_thread_id, WM_QUIT, 0, 0); | ||
} | ||
} | ||
HINSTANCE g_hInst = 0; | ||
|
||
class CPowerRenameClassLocalFactory : public IClassFactory | ||
{ | ||
public: | ||
CPowerRenameClassLocalFactory(_In_ REFCLSID clsid) : | ||
_clsid(clsid) | ||
{ | ||
} | ||
|
||
// IUnknown methods | ||
IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppv) | ||
{ | ||
static const QITAB qit[] = { | ||
QITABENT(CPowerRenameClassLocalFactory, IClassFactory), | ||
{ 0 } | ||
}; | ||
return QISearch(this, qit, riid, ppv); | ||
} | ||
|
||
IFACEMETHODIMP_(ULONG) | ||
AddRef() | ||
{ | ||
return ++_refCount; | ||
} | ||
|
||
IFACEMETHODIMP_(ULONG) | ||
Release() | ||
{ | ||
LONG refCount = --_refCount; | ||
return refCount; | ||
} | ||
|
||
// IClassFactory methods | ||
IFACEMETHODIMP CreateInstance(_In_opt_ IUnknown* punkOuter, _In_ REFIID riid, _Outptr_ void** ppv) | ||
{ | ||
*ppv = NULL; | ||
HRESULT hr; | ||
if (punkOuter) | ||
{ | ||
hr = CLASS_E_NOAGGREGATION; | ||
} | ||
else | ||
{ | ||
if (_clsid == CLSID_PowerRenameMenu) | ||
{ | ||
hr = CPowerRenameMenu::s_CreateInstance(punkOuter, riid, ppv); | ||
} | ||
else | ||
{ | ||
hr = CLASS_E_CLASSNOTAVAILABLE; | ||
} | ||
} | ||
return hr; | ||
} | ||
|
||
IFACEMETHODIMP LockServer(BOOL) | ||
{ | ||
return S_OK; | ||
} | ||
private: | ||
|
||
std::atomic<long> _refCount; | ||
CLSID _clsid; | ||
}; | ||
|
||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, | ||
_In_opt_ HINSTANCE , | ||
_In_ LPWSTR lpCmdLine, | ||
_In_ int nCmdShow) | ||
{ | ||
main_thread_id = GetCurrentThreadId(); | ||
winrt::init_apartment(); | ||
g_hInst = hInstance; | ||
auto factory = std::make_unique<CPowerRenameClassLocalFactory>(CLSID_PowerRenameMenu); | ||
DWORD token; | ||
if (!SUCCEEDED(CoRegisterClassObject(CLSID_PowerRenameMenu, factory.get(), CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &token))) | ||
{ | ||
return 1; | ||
} | ||
|
||
// Run msg loop for the local COM server | ||
run_message_loop(); | ||
|
||
CoRevokeClassObject(token); | ||
winrt::uninit_apartment(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<ProjectGuid>{0485F45C-EA7A-4BB5-804B-3E8D14699387}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>PowerRenameUWPUI</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v142</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" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<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)|$(Platform)'=='Release|x64'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<IncludePath>..\lib\;..\ui\;..\dll\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<IncludePath>..\lib\;..\ui\;..\dll\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>false</ConformanceMode> | ||
<LanguageStandard>stdcpplatest</LanguageStandard> | ||
<AdditionalIncludeDirectories>..\;..\..\..\common;..\..\..\common\telemetry;..\..\</AdditionalIncludeDirectories> | ||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalDependencies>WindowsApp.lib;Comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>false</ConformanceMode> | ||
<LanguageStandard>stdcpplatest</LanguageStandard> | ||
<AdditionalIncludeDirectories>..\;..\..\..\common;..\..\..\common\telemetry;..\..\</AdditionalIncludeDirectories> | ||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalDependencies>WindowsApp.lib;Comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClInclude Include="..\ui\resource.h" /> | ||
<ClInclude Include="stdafx.h" /> | ||
<ClInclude Include="targetver.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="..\dll\PowerRenameExt.cpp" /> | ||
<ClCompile Include="PowerRenameUWPUI.cpp" /> | ||
<ClCompile Include="stdafx.cpp"> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\common\common.vcxproj"> | ||
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project> | ||
</ProjectReference> | ||
<ProjectReference Include="..\lib\PowerRenameLib.vcxproj"> | ||
<Project>{51920f1f-c28c-4adf-8660-4238766796c2}</Project> | ||
</ProjectReference> | ||
<ProjectReference Include="..\ui\PowerRenameUI.vcxproj"> | ||
<Project>{0e072714-d127-460b-afad-b4c40b412798}</Project> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Image Include="..\ui\PowerRename.ico" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ResourceCompile Include="..\ui\PowerRenameUI.rc" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
49 changes: 49 additions & 0 deletions
49
src/modules/powerrename/UWPui/PowerRenameUWPUI.vcxproj.filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="targetver.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="stdafx.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="..\ui\resource.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="PowerRenameUWPUI.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="stdafx.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\dll\PowerRenameExt.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Image Include="..\ui\PowerRename.ico"> | ||
<Filter>Resource Files</Filter> | ||
</Image> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ResourceCompile Include="..\ui\PowerRenameUI.rc"> | ||
<Filter>Resource Files</Filter> | ||
</ResourceCompile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "stdafx.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include "targetver.h" | ||
|
||
#include <Unknwn.h> | ||
#include <winrt/base.h> | ||
#include <Shlwapi.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
// // Including SDKDDKVer.h defines the highest available Windows platform. | ||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and | ||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. | ||
#include <SDKDDKVer.h> |
Oops, something went wrong.