| 202 | } |
| 203 | |
| 204 | NVAPI_INTERFACE |
| 205 | NvAPI_DISP_GetDisplayIdByDisplayName(const char *displayName, NvU32 *displayId) { |
| 206 | struct MonitorEnumInfo { |
| 207 | std::string name; |
| 208 | HMONITOR handle; |
| 209 | bool is_primary; |
| 210 | }; |
| 211 | |
| 212 | MonitorEnumInfo info; |
| 213 | info.name = displayName; |
| 214 | info.handle = nullptr; |
| 215 | ::EnumDisplayMonitors( |
| 216 | nullptr, nullptr, |
| 217 | [](HMONITOR hmon, HDC hdc, LPRECT rect, LPARAM lp) -> BOOL { |
| 218 | auto data = reinterpret_cast<MonitorEnumInfo *>(lp); |
| 219 | |
| 220 | ::MONITORINFOEXW monitor_info; |
| 221 | monitor_info.cbSize = sizeof(monitor_info); |
| 222 | |
| 223 | if (!::GetMonitorInfoW(hmon, reinterpret_cast<MONITORINFO *>(&monitor_info))) |
| 224 | return TRUE; |
| 225 | |
| 226 | if (data->name != str::fromws(monitor_info.szDevice)) |
| 227 | return TRUE; |
| 228 | |
| 229 | data->handle = hmon; |
| 230 | data->is_primary = monitor_info.dwFlags & MONITORINFOF_PRIMARY; |
| 231 | return FALSE; |
| 232 | }, |
| 233 | reinterpret_cast<LPARAM>(&info) |
| 234 | ); |
| 235 | |
| 236 | if (!info.handle) |
| 237 | return NVAPI_NVIDIA_DEVICE_NOT_FOUND; |
| 238 | |
| 239 | *displayId = info.is_primary ? WMTGetPrimaryDisplayId() : WMTGetSecondaryDisplayId(); |
| 240 | |
| 241 | return NVAPI_OK; |
| 242 | } |
| 243 | |
| 244 | NVAPI_INTERFACE |
| 245 | NvAPI_D3D_GetObjectHandleForResource(IUnknown *pDevice, IUnknown *pResource, NVDX_ObjectHandle *pHandle) { |
nothing calls this directly
no test coverage detected