You can do it using WMI.
int bitDepth = -1;
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( SUCCEEDED( hr ) )
{
// hr = CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL );
if ( SUCCEEDED( hr ) )
{
IWbemLocator* pLoc = NULL;
hr = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (void**)&pLoc );
if ( SUCCEEDED( hr ) )
{
IWbemServices* pSvc = NULL;
hr = pLoc->ConnectServer( BSTR( L"ROOT\\CIMV2" ), NULL, NULL, 0, NULL, 0, 0, &pSvc );
if ( SUCCEEDED( hr ) )
{
hr = CoSetProxyBlanket( pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
if ( SUCCEEDED( hr ) )
{
IEnumWbemClassObject* pEnumerator = NULL;
hr = pSvc->ExecQuery( L"WQL", L"SELECT * FROM Win32_DisplayConfiguration", WBEM_FLAG_FORWARD_ONLY/* | WBEM_FLAG_RETURN_IMMEDIATELY*/, NULL, &pEnumerator );
if ( SUCCEEDED( hr ) )
{
IWbemClassObject* pDisplayObject = NULL;
ULONG numReturned = 0;
hr = pEnumerator->Next( WBEM_INFINITE, 1, &pDisplayObject, &numReturned );
if ( numReturned != 0 )
{
VARIANT vtProp;
pDisplayObject->Get( L"BitsPerPel", 0, &vtProp, 0, 0 );
bitDepth = vtProp.uintVal;
}
}
pEnumerator->Release();
}
}
pSvc->Release();
}
pLoc->Release();
}
}
// bitDepth wshould now contain the bitDepth or -1 if it failed for some reason.