Created
January 9, 2019 08:40
-
-
Save fknaopen/ce9d42eaf861ec3e91a5c5847566ff5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LONG GetCurrentTopology(DISPLAYCONFIG_TOPOLOGY_ID& currentTopology) | |
{ | |
LONG lRet = ERROR_SUCCESS; | |
UINT32 numPathInfoArrayElements = 0; | |
UINT32 numModeInfoArrayElements = 0; | |
DISPLAYCONFIG_PATH_INFO emptyPathInfo = { 0 }; | |
DISPLAYCONFIG_MODE_INFO emptyModeInfo = { 0 }; | |
std::vector<DISPLAYCONFIG_PATH_INFO> vecDisplayConfigPathInfo; | |
std::vector<DISPLAYCONFIG_MODE_INFO> vecDisplayConfigModeInfo; | |
currentTopology = DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32; | |
do | |
{ | |
vecDisplayConfigPathInfo.clear(); | |
vecDisplayConfigModeInfo.clear(); | |
lRet = ::GetDisplayConfigBufferSizes(QDC_DATABASE_CURRENT, &numPathInfoArrayElements, &numModeInfoArrayElements); | |
if (ERROR_SUCCESS != lRet) | |
{ | |
// Log | |
// std::cout << "Failed to get display config buffer size, error: " << std::hex << lRet << std::endl; | |
break; | |
} | |
vecDisplayConfigPathInfo.resize(numPathInfoArrayElements, emptyPathInfo); | |
vecDisplayConfigModeInfo.resize(numModeInfoArrayElements, emptyModeInfo); | |
lRet = ::QueryDisplayConfig(QDC_DATABASE_CURRENT, | |
&numPathInfoArrayElements, vecDisplayConfigPathInfo.data(), | |
&numModeInfoArrayElements, vecDisplayConfigModeInfo.data(), | |
¤tTopology); | |
if (ERROR_SUCCESS != lRet) | |
{ | |
// Log | |
// std::cout << "Failed to query display config path and mode info, error: " << std::hex << lRet << std::endl; | |
} | |
} while (ERROR_INSUFFICIENT_BUFFER == lRet); | |
return lRet; | |
} | |
int main() | |
{ | |
DISPLAYCONFIG_TOPOLOGY_ID m = DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32; | |
if (SUCCEEDED(GetCurrentTopology(m))) | |
{ | |
std::cout << "current topology: " << m; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment