mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[PowerRename][ImageResizer] Tier1 Win11 Context menu (#19000)
* Test win11 tier1 context menu
* Try to test signing
* Cleanup
* Cleanup project file
* Sign dll
Add PowerToys preffix
Add assets to installer
* expect.txt
* Switch to named pipes
Unregister package on uninstall
Remove unneeded files
Cleanup
* Bring back check if package registered but use per-user method
* Fix win11 check
* expect.txt
* Check if package already registered
* Revert "Check if package already registered"
FindPackages() method needs admin privileges.
This reverts commit 5af584fed4.
* Fix PowerRename args checking
* Cleanup assets
* Tier1 context menu ImageResizer
Minor cleanups
Move logic to package.h
* [WIP] Signing and installer
Expect.txt
* Localized context menu title
* Retarget everything 10.0.18362.0 -> 10.0.19041.0
* Address PR comments
- check if selection renamable
- minor cleanup
- struct initialization
* Fix ImageResizerLib project configuration
* More Windows version updates
* Remove unneeded file & try fix resource build error
* Add Microsoft.PowerToys prefix to packages
* Test
* Fix convert-resx-to-rc.ps1 script issue causing resource files compile error
Don't generate empty STRINGTABLE for resx files without data
* Avoid duplicate context menu items
* [BugReportTool] Report installed context menu packages
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="EventViewer.cpp" />
|
||||
<ClCompile Include="InstallationFolder.cpp" />
|
||||
<ClCompile Include="Package.cpp" />
|
||||
<ClCompile Include="ProcessesList.cpp" />
|
||||
<ClCompile Include="ReportMonitorInfo.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
@@ -68,6 +69,7 @@
|
||||
<ClInclude Include="..\..\..\deps\cziplib\src\zip.h" />
|
||||
<ClInclude Include="EventViewer.h" />
|
||||
<ClInclude Include="InstallationFolder.h" />
|
||||
<ClInclude Include="Package.h" />
|
||||
<ClInclude Include="ReportMonitorInfo.h" />
|
||||
<ClInclude Include="..\..\..\common\utils\json.h" />
|
||||
<ClInclude Include="RegistryUtils.h" />
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<ClCompile Include="XmlDocumentEx.cpp" />
|
||||
<ClCompile Include="InstallationFolder.cpp" />
|
||||
<ClCompile Include="ProcessesList.cpp" />
|
||||
<ClCompile Include="Package.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="ZipTools">
|
||||
@@ -33,5 +34,6 @@
|
||||
<ClInclude Include="EventViewer.h" />
|
||||
<ClInclude Include="XmlDocumentEx.h" />
|
||||
<ClInclude Include="InstallationFolder.h" />
|
||||
<ClInclude Include="Package.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <common/utils/timeutil.h>
|
||||
#include <common/utils/exec.h>
|
||||
|
||||
#include "Package.h"
|
||||
#include "ReportMonitorInfo.h"
|
||||
#include "RegistryUtils.h"
|
||||
#include "EventViewer.h"
|
||||
@@ -351,6 +352,8 @@ int wmain(int argc, wchar_t* argv[], wchar_t*)
|
||||
|
||||
ReportInstallerLogs(tempDir, reportDir);
|
||||
|
||||
ReportInstalledContextMenuPackages(reportDir);
|
||||
|
||||
// Zip folder
|
||||
auto zipPath = path::path(saveZipPath);
|
||||
|
||||
|
||||
78
tools/BugReportTool/BugReportTool/Package.cpp
Normal file
78
tools/BugReportTool/BugReportTool/Package.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "Package.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Management.Deployment.h>
|
||||
|
||||
std::optional<winrt::Windows::ApplicationModel::Package> GetPackage(std::wstring packageDisplayName)
|
||||
{
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::Management::Deployment;
|
||||
|
||||
PackageManager packageManager;
|
||||
|
||||
for (auto const& package : packageManager.FindPackagesForUser({}))
|
||||
{
|
||||
const auto& packageFullName = std::wstring{ package.Id().FullName() };
|
||||
|
||||
if (packageFullName.contains(packageDisplayName))
|
||||
{
|
||||
return { package };
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::wstringstream GetPackageInfo(winrt::Windows::ApplicationModel::Package package) {
|
||||
std::wstringstream packageInfo;
|
||||
packageInfo << L"Display name: " << std::wstring(package.DisplayName()) << std::endl;
|
||||
packageInfo << L"Full name: " << std::wstring(package.Id().FullName()) << std::endl;
|
||||
packageInfo << L"Version: " << package.Id().Version().Major << L"."
|
||||
<< package.Id().Version().Minor << L"."
|
||||
<< package.Id().Version().Build << L"."
|
||||
<< package.Id().Version().Revision << L"." << std::endl;
|
||||
packageInfo << L"Publisher: " << std::wstring(package.Id().Publisher()) << std::endl;
|
||||
packageInfo << L"Status: " << (package.Status().VerifyIsOK() ? std::wstring(L"OK") : std::wstring(L"Not OK")) << std::endl;
|
||||
|
||||
return packageInfo;
|
||||
}
|
||||
|
||||
void ReportInstalledContextMenuPackages(const std::filesystem::path& reportDir)
|
||||
{
|
||||
const wchar_t* ImageResizerContextMenuPackageDisplayName = L"ImageResizerContextMenu";
|
||||
const wchar_t* PowerRenameContextMenuPackageDisplayName = L"PowerRenameContextMenu";
|
||||
|
||||
auto reportPath = reportDir;
|
||||
reportPath.append("context-menu-packages.txt");
|
||||
|
||||
std::wofstream packagesReport(reportPath);
|
||||
|
||||
try
|
||||
{
|
||||
auto imageResizerPackage = GetPackage(ImageResizerContextMenuPackageDisplayName);
|
||||
if (imageResizerPackage)
|
||||
{
|
||||
packagesReport << GetPackageInfo(*imageResizerPackage).str() << std::endl;
|
||||
}
|
||||
|
||||
auto powerRenamePackage = GetPackage(PowerRenameContextMenuPackageDisplayName);
|
||||
if (powerRenamePackage)
|
||||
{
|
||||
packagesReport << GetPackageInfo(*powerRenamePackage).str() << std::endl;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
printf("Failed to report installed context menu packages");
|
||||
}
|
||||
}
|
||||
13
tools/BugReportTool/BugReportTool/Package.h
Normal file
13
tools/BugReportTool/BugReportTool/Package.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Management.Deployment.h>
|
||||
|
||||
std::optional<winrt::Windows::ApplicationModel::Package> GetPackage(std::wstring packageDisplayName);
|
||||
std::wstringstream GetPackageInfo(winrt::Windows::ApplicationModel::Package package);
|
||||
void ReportInstalledContextMenuPackages(const std::filesystem::path& reportDir);
|
||||
Reference in New Issue
Block a user