MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / GetSizeForDevID

Function GetSizeForDevID

Source/Falcor/Core/Platform/MonitorInfo.cpp:90–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool GetSizeForDevID(const std::wstring& TargetDevID, short& WidthMm, short& HeightMm)
91{
92 HDEVINFO devInfo = SetupDiGetClassDevsEx(
93 &GUID_CLASS_MONITOR, // class GUID
94 NULL, // enumerator
95 NULL, // HWND
96 DIGCF_PRESENT, // Flags //DIGCF_ALLCLASSES|
97 NULL, // device info, create a new one.
98 NULL, // machine name, local machine
99 NULL
100 ); // reserved
101
102 if (NULL == devInfo)
103 return false;
104
105 bool bRes = false;
106
107 for (ULONG i = 0; ERROR_NO_MORE_ITEMS != GetLastError(); ++i)
108 {
109 SP_DEVINFO_DATA devInfoData;
110 memset(&devInfoData, 0, sizeof(devInfoData));
111 devInfoData.cbSize = sizeof(devInfoData);
112
113 if (SetupDiEnumDeviceInfo(devInfo, i, &devInfoData))
114 {
115 TCHAR Instance[MAX_DEVICE_ID_LEN];
116 SetupDiGetDeviceInstanceId(devInfo, &devInfoData, Instance, MAX_DEVICE_ID_LEN, NULL);
117
118 std::wstring sInstance(Instance);
119
120 if (sInstance.find(TargetDevID) == std::wstring::npos)
121 continue;
122
123 HKEY hDevRegKey = SetupDiOpenDevRegKey(devInfo, &devInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
124
125 if (!hDevRegKey || (hDevRegKey == INVALID_HANDLE_VALUE))
126 continue;
127
128 bRes = GetMonitorSizeFromEDID(hDevRegKey, WidthMm, HeightMm);
129
130 RegCloseKey(hDevRegKey);
131 }
132 }
133 SetupDiDestroyDeviceInfoList(devInfo);
134 return bRes;
135}
136
137BOOL DisplayDeviceFromHMonitor(HMONITOR hMonitor, DISPLAY_DEVICE& ddMonOut)
138{

Callers 1

MonitorEnumProcFunction · 0.85

Calls 1

GetMonitorSizeFromEDIDFunction · 0.85

Tested by

no test coverage detected