How to obtain information from the DirectX diagnostic tool dialog box

Source: Internet
Author: User

Recently I have made some annoying things. Basically, I want to obtain data similar to that in the DirectX diagnostic tool dialog box. Here, I tried my best to find it on the Internet. This is generally the case when we are not familiar with this aspect. I found a bunch of messy information. For example, to obtain system information, you can use getverionex to obtain memory information. You can use functions such as getglobalmemstatus and WMI to obtain information like a video card. Each small item can be obtained in a different way. However, all the data in dxdiag is available. We may want to directly obtain this, so that we do not need to use so many methods to obtain different information.

Dxdiag is used to obtain data. For games that have been developed using DirectX, this data should be compared. I don't understand. Dxdiag has already exposed a COM interface to us and can be used directly. For more information, see the dx sdk help documentation. When using COM, it is usually first initialized, then get the desired interface, query, and finally remember to uninstall it. If com is initialized for multiple times in the program, the data will fail. Therefore, only COM can be initialized once.

Here is a code for obtaining hardware acceleration information. It is similar to getting other data.

Hresultgetdirectfunviadxdiag (bool * bdirectdraw, bool * bdirect3d, bool * bagp) <br/>{< br/> hresult hr; <br/> bool bcleanupcom = false; </P> <p> bool bsuccessgettingmajor = false; <br/> bool bsuccessgettingminor = false; <br/> bool bsuccessgettingletter = false; </P> <p> If (! Bdirectdraw |! Bdirect3d |! Bagp) <br/>{< br/> return e_fail; <br/>}</P> <p> // init COM. com may fail if its already been inited with a different <br/> // concurrency model. and if it fails you shouldn't release it. <br/> hR = coinitialize (null); <br/> bcleanupcom = succeeded (HR ); </P> <p> // get an idxdiagprovider <br/> bool bgotdirectxversion = false; <br/> idxdiagprovider * pdxdiagprovider = NULL; <br/> hR = cocreateinstance (clsid_dxdiagprovider, <br/> null, <br/> clsctx_inproc_server, <br/> iid_idxdiagprovider, <br/> (lpvoid *) & pdxdiagprovider ); <br/> If (succeeded (HR) <br/>{< br/> // fill out a dxdiag_init_params struct <br/> dxdiag_init_params dxdiaginitparam; <br/> zeromemory (& dxdiaginitparam, sizeof (dxdiag_init_params); <br/> dxdiaginitparam. dwsize = sizeof (dxdiag_init_params); <br/> dxdiaginitparam. dwdxdiagheaderversion = dxdiag_dx9_sdk_version; <br/> dxdiaginitparam. ballowwhqlchecks = false; <br/> dxdiaginitparam. preserved = NULL; </P> <p> // init the m_pdxdiagprovider <br/> hR = pdxdiagprovider-> initialize (& dxdiaginitparam ); <br/> If (succeeded (HR) <br/>{< br/> idxdiagcontainer * pdxdiagroot = NULL; <br/> idxdiagcontainer * pdxdiagsysteminfo = NULL; <br/> idxdiagcontainer * pdxdiagdispaly = NULL; </P> <p> // get the dxdiag root container <br/> hR = pdxdiagprovider-> getrootcontainer (& pdxdiagroot ); <br/> If (succeeded (HR) <br/>{</P> <p> hR = pdxdiagroot-> getchildcontainer (L "dxdiag_displaydevices.0", & pdxdiagdispaly ); </P> <p> If (succeeded (HR) <br/>{< br/> variant var; <br/> variantinit (& var ); <br/> bool bddaccelerationenabled, <br/> b3daccelerationexists, <br/> b3daccelerationenabled, <br/> bagpenabled, <br/> bagpexists, <br/> disabled; </P> <p> hR = pdxdiagdispaly-> getprop (L "bddaccelerationenabled", & var); <br/> If (succeeded (HR) & var. vt = vt_bool) <br/>{< br/> * bdirectdraw = bddaccelerationenabled = var. boolval; <br/>}</P> <p> variantclear (& var ); </P> <p> // hR = pdxdiagdispaly-> getprop (L "b3daccelerationexists", & var); <br/> // If (succeeded (HR) & var. vt = vt_bool) <br/> // {<br/> // b3daccelerationexists = var. boolval; <br/>//} <br/> // variantclear (& var ); </P> <p> hR = pdxdiagdispaly-> getprop (L "b3daccelerationenabled", & var); <br/> If (succeeded (HR) & var. vt = vt_bool) <br/>{< br/> * bdirect3d = b3daccelerationenabled = var. boolval; <br/>}</P> <p> variantclear (& var); </P> <p> hR = pdxdiagdispaly-> getprop (L "bagpenabled ", & var); <br/> If (succeeded (HR) & var. vt = vt_bool) <br/>{< br/> * bagp = bagpenabled = var. boolval; <br/>}</P> <p> variantclear (& var ); </P> <p> // hR = pdxdiagdispaly-> getprop (L "bagpexists", & var); <br/> // If (succeeded (HR) & var. vt = vt_bool) <br/> // {<br/> // bagpexists = var. boolval; <br/>//} <br/> // variantclear (& var ); <br/> // hR = pdxdiagdispaly-> getprop (L "bagpexistencevalid", & var); <br/> // If (succeeded (HR) & var. vt = vt_bool) <br/> // {<br/> // bagpexistencevalid = var. boolval; <br/>//} <br/> // variantclear (& var ); </P> <p >}</P> <p> pdxdiagroot-> release (); <br/>}</P> <p> pdxdiagprovider-> release (); <br/>}</P> <p> If (bcleanupcom) <br/> couninitialize (); </P> <p> If (bgotdirectxversion) <br/> return s_ OK; <br/> else <br/> return e_fail; </P> <p> return e_fail; <br/>}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.