mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
* [Updating] Refactor autoupdate mechanism to use Settings window buttons * [Updating] Don't use underscores in update_state (#11029) * [Updating] Rename action_runner to be consisent with accepted format * [Updating] Make UpdateState values explicit * [Setup] Set default bootstrapper log severity to debug * [BugReport] Include all found bootstrapper logs * [Setup] Use capital letter for ActionRunner * [Updating] Simple UI to test UpdateState * [Action Runner] cleanup and coding style * [BugReportTool] fix coding convension * [Auto-update][PT Settings] Updated general page in the Settings (#11227) * [Auto-update][PT Settings] File watcher monitoring UpdateState.json (#11282) * Handle button clicks (#11288) * [Updating] Document ActionRunner cmd flags * [Auto-update][PT Settings] Updated UI (#11335) * [Updating] Do not reset update state when msi cancellation detected * [Updating] Directly launch update_now PT action instead of using custom URI scheme * Checking for updates UI (#11354) * [Updating] Fix cannotDownload state in action runner * [Updating] Reset update state to CannotDownload if action runner encountered an error * [Updating][PT Settings] downloading label, disable button in error state * Changed error message * [Updating rename CannotDownload to ErrorDownloading * [Updating] Add trace logging for Check for updates callback * [Updating][PT Settings] simplify downloading checks * [Updating][PT Settings] Updated text labels * [Updating][PT Settings] Retry to load settings if failed * [Updating][PT Settings] Text fix * [Updating][PT Settings] Installed version links removed * [Updating][PT Settings] Error text updated * [Updating][PT Settings] Show label after version checked * [Updating][PT Settings] Text foreground fix * [Updating][PT Settings] Clean up * [Updating] Do not reset releasePageUrl in case of error/cancellation * [Updating][PT Settings] fixed missing string * [Updating][PT Settings] checked for updates state fix Co-authored-by: yuyoyuppe <a.yuyoyuppe@gmail.com> Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com> Co-authored-by: Enrico Giordani <enrico.giordani@gmail.com>
84 lines
2.7 KiB
C++
84 lines
2.7 KiB
C++
#pragma once
|
|
#include "ReportMonitorInfo.h"
|
|
#include <Windows.h>
|
|
#include <filesystem>
|
|
#include "../../../src/common/utils/winapi_error.h"
|
|
using namespace std;
|
|
|
|
namespace
|
|
{
|
|
int BuildMonitorInfoReport(std::wostream& os)
|
|
{
|
|
struct capture
|
|
{
|
|
std::wostream* os = nullptr;
|
|
};
|
|
|
|
auto callback = [](HMONITOR monitor, HDC, RECT*, LPARAM prm) -> BOOL {
|
|
std::wostream& os = *((capture*)prm)->os;
|
|
MONITORINFOEX mi;
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
if (GetMonitorInfoW(monitor, &mi))
|
|
{
|
|
os << "GetMonitorInfo OK\n";
|
|
DISPLAY_DEVICE displayDevice = { sizeof(displayDevice) };
|
|
|
|
DWORD i = 0;
|
|
while (EnumDisplayDevicesW(mi.szDevice, i++, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
|
|
{
|
|
const bool active = displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE;
|
|
const bool mirroring = displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER;
|
|
os << "EnumDisplayDevices OK:\n"
|
|
<< "\tMirroring = " << mirroring << '\n'
|
|
<< "\tActive = " << active << '\n'
|
|
<< "\tDeviceID = " << displayDevice.DeviceID << '\n'
|
|
<< "\tDeviceKey = " << displayDevice.DeviceKey << '\n'
|
|
<< "\tDeviceName = " << displayDevice.DeviceName << '\n'
|
|
<< "\tDeviceString = " << displayDevice.DeviceString << '\n';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
auto message = get_last_error_message(GetLastError());
|
|
os << "GetMonitorInfo FAILED: " << (message.has_value() ? message.value() : L"") << '\n';
|
|
}
|
|
return TRUE;
|
|
};
|
|
|
|
capture c;
|
|
c.os = &os;
|
|
if (EnumDisplayMonitors(nullptr, nullptr, callback, (LPARAM)&c))
|
|
{
|
|
os << "EnumDisplayMonitors OK\n";
|
|
}
|
|
else
|
|
{
|
|
auto message = get_last_error_message(GetLastError());
|
|
os << "EnumDisplayMonitors FAILED: " << (message.has_value() ? message.value() : L"") << '\n';
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void ReportMonitorInfo(const filesystem::path& tmpDir)
|
|
{
|
|
auto monitorReportPath = tmpDir;
|
|
monitorReportPath.append("monitor-report-info.txt");
|
|
|
|
try
|
|
{
|
|
wofstream monitorReport(monitorReportPath);
|
|
monitorReport << "GetSystemMetrics = " << GetSystemMetrics(SM_CMONITORS) << '\n';
|
|
BuildMonitorInfoReport(monitorReport);
|
|
}
|
|
catch (std::exception& ex)
|
|
{
|
|
printf("Failed to report monitor info. %s\n", ex.what());
|
|
}
|
|
catch (...)
|
|
{
|
|
printf("Failed to report monitor info\n");
|
|
}
|
|
}
|