添加部分代码
This commit is contained in:
parent
d9fb6fb6c8
commit
a626a07b15
@ -158,19 +158,53 @@ int SysInfoUtil::GetInfoByEnumDisplayDevices()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SysInfoUtil::GetInfoByEnumDisplayDevicesA()
|
||||||
|
{
|
||||||
|
DISPLAY_DEVICEA dd;
|
||||||
|
DEVMODEA dm;
|
||||||
|
for (int i = 0;; i++) {
|
||||||
|
ZeroMemory(&dd, sizeof(dd));
|
||||||
|
dd.cb = sizeof(dd);
|
||||||
|
BOOL ret = (EnumDisplayDevicesA(NULL, i, &dd, 0));
|
||||||
|
if (ret == FALSE)
|
||||||
|
break;
|
||||||
|
ZeroMemory(&dm, sizeof(dm));
|
||||||
|
dm.dmSize = sizeof(dm);
|
||||||
|
if (EnumDisplaySettingsA(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm)) {
|
||||||
|
std::cout << "Device #" << i << " Information:" << std::endl;
|
||||||
|
std::cout << "Device Name: " << dd.DeviceName << std::endl;
|
||||||
|
std::cout << "Device String: " << dd.DeviceString << std::endl;
|
||||||
|
std::cout << "State: " << (dd.StateFlags & DISPLAY_DEVICE_ACTIVE ? "Active" : "Inactive") << std::endl;
|
||||||
|
std::cout << "Device ID: " << dd.DeviceID << std::endl;
|
||||||
|
std::cout << "Device Key: " << dd.DeviceKey << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void SysInfoUtil::GetInfoByEnumDisplayMonitors()
|
void SysInfoUtil::GetInfoByEnumDisplayMonitors()
|
||||||
{
|
{
|
||||||
wcout << "=====GetInfoByEnumDisplayMonitors start=====" << endl;
|
wcout << "=====GetInfoByEnumDisplayMonitors start=====" << endl;
|
||||||
// 枚举显示器
|
// 枚举显示器
|
||||||
EnumDisplayMonitors(NULL, NULL, [](HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -> BOOL {
|
EnumDisplayMonitors(NULL, NULL, [](HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -> BOOL {
|
||||||
|
// 获取显示器的设备名称
|
||||||
MONITORINFOEX monitorInfo;
|
MONITORINFOEX monitorInfo;
|
||||||
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
||||||
if (GetMonitorInfo(hMonitor, &monitorInfo)) {
|
if (GetMonitorInfo(hMonitor, &monitorInfo)) {
|
||||||
// 输出友好名称
|
std::wcout << L"name: " << monitorInfo.szDevice << std::endl;
|
||||||
wcout << "szDevice:" << monitorInfo.szDevice << endl;
|
|
||||||
wcout << "right:" << monitorInfo.rcMonitor.right << endl;
|
// 获取显示器的屏幕区域
|
||||||
wcout << "bottom:" << monitorInfo.rcMonitor.bottom << endl;
|
std::wcout << L"rect: left(" << lprcMonitor->left << ", " << lprcMonitor->top
|
||||||
|
<< "), right(" << lprcMonitor->right << ", " << lprcMonitor->bottom << ")" << std::endl;
|
||||||
|
|
||||||
|
// 获取显示器的分辨率
|
||||||
|
std::wcout << L"dpi: w=" << lprcMonitor->right - lprcMonitor->left
|
||||||
|
<< ", h=" << lprcMonitor->bottom - lprcMonitor->top << std::endl;
|
||||||
|
|
||||||
|
std::wcout << L"===================" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}, 0);
|
}, 0);
|
||||||
wcout << "=====GetInfoByEnumDisplayMonitors end=====" << endl;
|
wcout << "=====GetInfoByEnumDisplayMonitors end=====" << endl;
|
||||||
|
@ -16,6 +16,8 @@ public:
|
|||||||
|
|
||||||
static int GetInfoByQueryDisplayConfig();
|
static int GetInfoByQueryDisplayConfig();
|
||||||
|
|
||||||
|
static void GetInfoByEnumDisplayDevicesA();
|
||||||
|
|
||||||
static int GetInfoByCfgmgr();
|
static int GetInfoByCfgmgr();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user