Comments (2)
struct MATCH_DISPLAY_CTX
{
LPCWSTR name;
HMONITOR hm;
};
static BOOL MatchDisplayName(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, LPARAM lParam)
{
struct MATCH_DISPLAY_CTX* ctx = (struct MATCH_DISPLAY_CTX*)lParam;
MONITORINFOEXW info = { .cbSize = sizeof(MONITORINFOEXW) };
if (GetMonitorInfoW(hMonitor, (LPMONITORINFO)&info))
{
if (wcscmp(ctx->name, info.szDevice) == 0)
{
ctx->hm = hMonitor;
return FALSE;
}
}
return TRUE;
}
HMONITOR
NWL_GetMonitorHandleByHwID(LPCWSTR hwId)
{
DWORD i, j;
int len;
WCHAR displayId[32];
DISPLAY_DEVICEW displayDevice = { .cb = sizeof(DISPLAY_DEVICEW) };
// MONITOR\XXXXXXX
if (wcsncmp(hwId, L"MONITOR\\", 8) != 0)
return NULL;
len = swprintf(displayId, 32, L"\\\\?\\DISPLAY#%s#", &hwId[8]);
if (len <= 0)
return NULL;
for (i = 0; EnumDisplayDevicesW(NULL, i, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME); i++)
{
DISPLAY_DEVICEW monitorDevice = { .cb = sizeof(DISPLAY_DEVICEW) };
for (j = 0; EnumDisplayDevicesW(displayDevice.DeviceName, j, &monitorDevice, EDD_GET_DEVICE_INTERFACE_NAME); j++)
{
//MonitorDevice.DeviceID
if (wcsncmp(monitorDevice.DeviceID, displayId, (size_t)len) == 0)
{
struct MATCH_DISPLAY_CTX ctx = { .name = displayDevice.DeviceName, .hm = NULL };
EnumDisplayMonitors(NULL, NULL, MatchDisplayName, (LPARAM) &ctx);
return ctx.hm;
}
}
}
return NULL;
}
from nwinfo.
void nwinfo_display(void)
{
DWORD iDevNum = 0;
DEVMODEA DevMode = { .dmSize = sizeof(DEVMODEA) };
DISPLAY_DEVICEA DisplayDevice = { .cb = sizeof(DISPLAY_DEVICEA) };
while (EnumDisplayDevicesA(NULL, iDevNum, &DisplayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
{
DWORD State = DisplayDevice.StateFlags;
printf("%s\n", DisplayDevice.DeviceName);
printf(" %s\n", DisplayDevice.DeviceString);
printf(" Device state: %s%s%s%s%s%s\n",
(State & DISPLAY_DEVICE_ACTIVE) ? "active" : "deactive",
(State & DISPLAY_DEVICE_MIRRORING_DRIVER) ? " mirroring" : "",
(State & DISPLAY_DEVICE_MODESPRUNED) ? " modespruned" : "",
(State & DISPLAY_DEVICE_PRIMARY_DEVICE) ? " primary" : "",
(State & DISPLAY_DEVICE_REMOVABLE) ? " removable" : "",
(State & DISPLAY_DEVICE_VGA_COMPATIBLE) ? " vga" : "");
if (EnumDisplaySettingsExA(DisplayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &DevMode, 0))
{
printf(" Current mode: %ux%u, %u Hz\n", DevMode.dmPelsWidth, DevMode.dmPelsHeight, DevMode.dmDisplayFrequency);
}
iDevNum++;
}
}
from nwinfo.
Related Issues (20)
- Help HOT 1
- XP 不支持 GetThreadGroupAffinity
- 检测 Windows 版本
- 列出 UEFI 启动项 HOT 2
- Switch to unicode character set
- 获取 CPU 核心温度/功耗 HOT 3
- IP_ADAPTER_ADDRESSES 在不同版本 Windows 下定义不同 HOT 2
- [feature request] high DPI support HOT 1
- Incorrect escape character for error message HOT 1
- Get the size of pagefile
- help HOT 5
- U盘或其它设备被占用、拔出后,还不能实时从设备列表中移除原设备信息显示 HOT 2
- 自定义窗口起始位置 HOT 1
- 隐藏敏感数据
- 获取 CPU TDP / PL1 / PL2 HOT 2
- Request to take a disk number as parameter in --disk command in CLI HOT 9
- Get GPU usage HOT 4
- Edit ProductPolicy HOT 1
- IP address lookup
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nwinfo.