HRESULT DXDiagNVUtil::GetProperty( LPCWSTR container_name0, LPCWSTR container_name1, LPCWSTR property_name, wstring * out_value ) { HRESULT hr = S_OK; IDxDiagContainer * pContainer; hr = GetChildContainer( container_name0, container_name1, &pContainer ); MSG_AND_RET_VAL_IF( FAILED(hr), "GetProperty(cn,cn,pn,&v) couldn't get child container!\n", hr ); hr = GetProperty( pContainer, property_name, out_value ); MSG_AND_RET_VAL_IF( FAILED(hr), "GetProperty(cn,cn,pn,&v) couldn't get container property!\n", hr ); SAFE_RELEASE( pContainer ); return( hr ); }
HRESULT DXDiagNVUtil::GetNumDisplayDevices( DWORD * out_pdwNumAdapters ) { HRESULT hr = S_OK; MSGVARNAME_AND_FAIL_IF_NULL( m_pDxDiagRoot ); MSGVARNAME_AND_FAIL_IF_NULL( out_pdwNumAdapters ); IDxDiagContainer * pChild; hr = GetChildContainer( L"DxDiag_DisplayDevices", & pChild ); MSG_AND_RET_VAL_IF( FAILED(hr), "GetNumDisplayDevices() Couldn't get display devices container!\n", hr ); hr = pChild->GetNumberOfChildContainers( out_pdwNumAdapters ); MSG_AND_BREAK_IF( FAILED(hr), "GetNumDisplayDevices() Couldn't get number of child containers!\n" ); SAFE_RELEASE( pChild ); return( hr ); }
HRESULT DXDiagNVUtil::GetDisplayDeviceNode( DWORD dwDeviceIndex, IDxDiagContainer ** ppNode ) { // fill *ppNode with pointer to the display device at index nDevice of the DXDiag_DisplayDevices container // you must SAFE_RELEASE( *ppNode ) outside of this function. HRESULT hr = S_OK; FAIL_IF_NULL( ppNode ); IDxDiagContainer * pDevicesNode; hr = GetChildContainer( L"DxDiag_DisplayDevices", & pDevicesNode ); MSG_AND_RET_VAL_IF( FAILED(hr), "GetDisplayDeviceNode() couldn't get devices node!\n", hr ); // Get the device at the appropriate index hr = GetChildByIndex( pDevicesNode, dwDeviceIndex, ppNode ); SAFE_RELEASE( pDevicesNode ); return( hr ); }
/*------------------------------------------------------------------ Retrieve various data through the IDxDiagContainer interface. The DXDiagNVUtil class provides a few convenient wrapper functions, and direct querries using the IDxDiagContainer COM object names are also supported. For a list of all the container and property COM object names, call ListAllDXDiagPropertyNames(..) ------------------------------------------------------------------*/ HRESULT GetGPUAndSystemInfo::GetData() { HRESULT hr = S_OK; //---------------------------------------------------------------------------- hr = m_DXDiagNVUtil.InitIDxDiagContainer(); MSG_AND_RET_VAL_IF( FAILED(hr), "Couldn't initialize DXDiagNVUtil!\n", hr ); wstring wstr; // Get the computer's machine name: m_DXDiagNVUtil.GetProperty( L"DxDiag_SystemInfo", L"szMachineNameEnglish", &wstr ); m_strMachineName = m_DXDiagNVUtil.WStringToString( &wstr ); FMsg("\n\n"); FMsg("------------------------------------------------------------------------\n"); FMsgW(L"machine name: %s\n", wstr.c_str() ); // Get info about physcial memory: m_DXDiagNVUtil.GetPhysicalMemoryInMB( & m_fSystemPhysicalMemoryMB ); FMsg("physical memory: %g MB\n", m_fSystemPhysicalMemoryMB ); // Get info about logical disks IDxDiagContainer * pContainer, *pChild; DWORD dwNumDisks; hr = m_DXDiagNVUtil.GetChildContainer( L"DxDiag_LogicalDisks", & pContainer ); if( SUCCEEDED(hr)) { pContainer->GetNumberOfChildContainers( & dwNumDisks ); wstring drive, space; FMsgW(L"logical disks: %d\n", dwNumDisks ); for( DWORD n=0; n < dwNumDisks; n++ ) { hr = m_DXDiagNVUtil.GetChildByIndex( pContainer, n, &pChild ); if( SUCCEEDED(hr) ) { m_DXDiagNVUtil.GetProperty( pChild, L"szDriveLetter", &drive ); m_DXDiagNVUtil.GetProperty( pChild, L"szFreeSpace", &space ); FMsgW(L" %s Free space = %s\n", drive.c_str(), space.c_str() ); SAFE_RELEASE( pChild ); } } SAFE_RELEASE( pContainer ); } FMsg("------------------------------------------------------------------------\n"); m_DXDiagNVUtil.GetDirectXVersion( &m_dwDXVersionMajor, &m_dwDXVersionMinor, &m_cDXVersionLetter ); FMsg("DirectX Version: %d.%d%c\n", m_dwDXVersionMajor, m_dwDXVersionMinor, m_cDXVersionLetter ); hr = m_DXDiagNVUtil.GetNumDisplayDevices( & m_dwNumDisplayDevices ); MSG_AND_RET_VAL_IF( FAILED(hr), "Couldn't GetNumDisplayDevices()\n", hr ); FMsg("Num Display Devices: %d\n", m_dwNumDisplayDevices ); string str; // for( DWORD dev=0; dev < m_dwNumDisplayDevices; dev ++ ) if( m_dwNumDisplayDevices > 0 ) { DWORD dev = 0; // get info from display devices m_DXDiagNVUtil.GetDisplayDeviceDescription( dev, & m_wstrDeviceDesc ); m_DXDiagNVUtil.GetDisplayDeviceNVDriverVersion( dev, & m_fDriverVersion ); m_DXDiagNVUtil.GetDisplayDeviceMemoryInMB( dev, & m_nDeviceMemoryMB ); // report the info via OutputDebugString FMsgW(L"Device %d Description: %s\n", dev, m_wstrDeviceDesc.c_str() ); FMsg( "Device %d Driver version: %g\n", dev, m_fDriverVersion ); FMsg( "Device %d Physical mem: %d MB\n", dev, m_nDeviceMemoryMB ); // Get info about AGP memory: wstring wstrAGPEnabled, wstrAGPExists, wstrAGPStatus; hr = m_DXDiagNVUtil.GetDisplayDeviceAGPMemoryStatus( dev, &wstrAGPEnabled, &wstrAGPExists, &wstrAGPStatus ); if( SUCCEEDED(hr)) { // create a string from the AGP status strings m_strAGPStatus = ""; str = m_DXDiagNVUtil.WStringToString( &wstrAGPEnabled ); m_strAGPStatus += "AGP Enabled = "; m_strAGPStatus += str; m_strAGPStatus += ", "; str = m_DXDiagNVUtil.WStringToString( &wstrAGPExists ); m_strAGPStatus += "AGP Exists = "; m_strAGPStatus += str; m_strAGPStatus += ", "; str = m_DXDiagNVUtil.WStringToString( &wstrAGPStatus ); m_strAGPStatus += "AGP Status = "; m_strAGPStatus += str; } FMsg("%s\n", m_strAGPStatus.c_str() ); wstring wstrNotes, wstrTestD3D9; m_DXDiagNVUtil.GetProperty( L"DxDiag_DisplayDevices", L"0", L"szTestResultD3D9English", &wstrTestD3D9 ); m_DXDiagNVUtil.GetProperty( L"DxDiag_DisplayDevices", L"0", L"szNotesEnglish", &wstrNotes ); str = m_DXDiagNVUtil.WStringToString( &wstrTestD3D9 ); FMsg("Device 0 szTestResultD3D9English = \"%s\"\n", str.c_str() ); str = m_DXDiagNVUtil.WStringToString( &wstrNotes ); FMsg("Device 0 szNotesEnglish = \"%s\"\n", str.c_str() ); } m_DXDiagNVUtil.GetDebugLevels( & m_wstrDxDebugLevels ); FMsg("DirectX Debug Levels:\n"); FMsgW(L"%s\n", m_wstrDxDebugLevels.c_str() ); // ListAllDXDiagPropertyNames() is slow // It prints out all nodes, child nodes, properties and their values // m_DXDiagNVUtil.ListAllDXDiagPropertyNames(); // Use a call like that below to print out a specific node and it's children. // For example, to list all the display device property names. /* m_DXDiagNVUtil.GetChildContainer( L"DxDiag_DisplayDevices", &pContainer ); m_DXDiagNVUtil.ListAllDXDiagPropertyNames( pContainer, L"DxDiag_DisplayDevices" ); SAFE_RELEASE( pContainer ); // */ m_DXDiagNVUtil.FreeIDxDiagContainer(); return( hr ); }