When diagnosing problems on users' machines, the hardware and OS information is very helpful. It takes a lot of effort to check the hardware information on the machine. Here is a quick and convenient method: Use the built-in windows tool.Dxdiag.exeTo generate a hardware detection report, and then read the report file.The sample code is as follows:
Startupinfo Si = {sizeof (SI), 0 }; <br/> process_information Pi = {0 }; <br/> tchar szcmdline [max_path] = _ T ("dxdiag.exe/WHQL: Off/T dxdiag_output.txt "); </P> <p> If (CreateProcess (<br/> null, <br/> szcmdline, <br/> null, <br/> null, <br/> true, <br/> null, <br/> & Si, <br/> & PI )) <br/>{</P> <p> waitforsingleobject (Pi. hprocess, infinite); // wait until the completion of dxdiag.exe execution <br/> closehandle (Pi. hprocess); <br/> closehandle (Pi. hthread); </P> <p> // read the dxdiag_output.txt file to obtain the hardware/OS information of the user's machine. <br/> handle hfile = createfile (_ T ("dxdiag_output.txt "), generic_read, file_share_read, null, open_existing, file_attribute_normal, null); <br/> If (hfile! = Invalid_handle_value) <br/>{< br/> DWORD dwbytesread = 0; <br/> char szbuffer [buffer_size]; <br/> readfile (hfile, szbuffer, BUFFER_SIZE-1, & dwbytesread, null); </P> <p>... </P> <p >}< br/> closehandle (hfile); <br/>}< br/>
> Original article copyright belongs to the author, reprint please indicate the source (http://blog.csdn.net/WinGeek/), thank you. <