[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:
Stefan Markovic
2022-06-30 22:10:14 +02:00
committed by GitHub
parent a0eacca17f
commit e637902892
148 changed files with 3163 additions and 384 deletions

View File

@@ -53,15 +53,60 @@ void App::OnLaunched(LaunchActivatedEventArgs const&)
{
LoggerHelpers::init_logger(moduleName, L"", LogSettings::powerRenameLoggerName);
#define BUFSIZE 4096 * 4
auto args = std::wstring{ GetCommandLine() };
size_t pos{ args.rfind(L"\\\\.\\pipe\\") };
std::wstring pipe_name;
if (pos != std::wstring::npos)
{
pipe_name = args.substr(pos);
}
HANDLE hStdin;
if (pipe_name.size() > 0)
{
while (1)
{
hStdin = CreateFile(
pipe_name.c_str(), // pipe name
GENERIC_READ | GENERIC_WRITE, // read and write
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
// Break if the pipe handle is valid.
if (hStdin != INVALID_HANDLE_VALUE)
break;
// Exit if an error other than ERROR_PIPE_BUSY occurs.
auto error = GetLastError();
if (error != ERROR_PIPE_BUSY)
{
break;
}
if (!WaitNamedPipe(pipe_name.c_str(), 3))
{
printf("Could not open pipe: 20 second wait timed out.");
}
}
}
else
{
hStdin = GetStdHandle(STD_INPUT_HANDLE);
}
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
if (hStdin == INVALID_HANDLE_VALUE)
{
Logger::error(L"Invalid input handle.");
ExitProcess(1);
}
#define BUFSIZE 4096 * 4
BOOL bSuccess;
WCHAR chBuf[BUFSIZE];
DWORD dwRead;
@@ -86,6 +131,7 @@ void App::OnLaunched(LaunchActivatedEventArgs const&)
if (!bSuccess)
break;
}
CloseHandle(hStdin);
Logger::debug(L"Starting PowerRename with {} files selected", g_files.size());