-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cpp
More file actions
57 lines (52 loc) · 2.38 KB
/
Copy pathApp.xaml.cpp
File metadata and controls
57 lines (52 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "pch.h"
#include "App.xaml.h"
#include "MainWindow.xaml.h"
#include "src/cleanup.hpp"
#include <shellapi.h>
#include <sstream>
namespace winrt::CryptoProCleanupModern::implementation
{
App::App()
{
}
void App::OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&)
{
int argc = 0;
wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
const cpc::CommandLineOptions options = cpc::ParseCommandLine(argc, argv);
if (argv) LocalFree(argv);
if (options.showHelp)
{
const std::wstring heading = std::wstring(L"CryptoPro Cleanup Utility ") + cpc::kVersion + L"\r\n\r\n";
MessageBoxW(nullptr,
(heading +
L"--scan Safe scan only\r\n"
L"--offline-scan <path> Safe disconnected-Windows scan\r\n"
L"--report <path> Report path\r\n"
L"--lang ru|en Interface/report language\r\n"
L"--resume <token> Internal restart continuation").c_str(),
L"CryptoPro Cleanup Utility", MB_OK | MB_ICONINFORMATION);
ExitProcess(0);
}
if (!options.offlineWindowsPath.empty()) ExitProcess(cpc::RunOfflineScanCommand(options));
if (options.scanOnly) ExitProcess(cpc::RunScanCommand(options));
// A resumed cleanup is an exact residual pass over the protected state.
// It must never fall through to the normal uninstaller confirmation UI.
if (!options.resumeToken.empty()) ExitProcess(cpc::RunResumeCommand(options.resumeToken, true));
try
{
auto mainWindow = winrt::make_self<MainWindow>();
mainWindow->InitializeSession(options.language, {}, options.languageExplicit);
window = *mainWindow;
window.Activate();
}
catch (winrt::hresult_error const& error)
{
const std::wstring detail = std::wstring(L"Modern UI initialization failed (0x") +
[&]() { std::wostringstream value; value << std::hex << static_cast<unsigned long>(error.code().value); return value.str(); }() +
L"): " + std::wstring(error.message().c_str());
OutputDebugStringW((detail + L"\r\n").c_str());
MessageBoxW(nullptr, detail.c_str(), L"CryptoPro Cleanup Utility", MB_OK | MB_ICONERROR);
}
}
}