MCPcopy Create free account
hub / github.com/3Shain/dxmt / NvAPI_DISP_GetDisplayIdByDisplayName

Function NvAPI_DISP_GetDisplayIdByDisplayName

src/nvapi/nvapi.cpp:204–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204NVAPI_INTERFACE
205NvAPI_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
244NVAPI_INTERFACE
245NvAPI_D3D_GetObjectHandleForResource(IUnknown *pDevice, IUnknown *pResource, NVDX_ObjectHandle *pHandle) {

Callers

nothing calls this directly

Calls 3

fromwsFunction · 0.85
WMTGetPrimaryDisplayIdFunction · 0.85
WMTGetSecondaryDisplayIdFunction · 0.85

Tested by

no test coverage detected