Windows API one-day training (74) getsysteminfo Function
On one occasion, I was developing a video compression program, and the compression algorithm was very efficient, that is, the multimedia instruction that needed to use the CPU. In the x86 field, there are currently two major CPUs: Intel and AMD. Their multimedia commands are different. To distinguish such different commands, you need to call the getsysteminfo function to obtain CPU information, and then call different dynamic connection libraries for multimedia data compression.
The getsysteminfo function is declared as follows:
Winbaseapi
Void
Winapi
Getsysteminfo (
_ Out lpsystem_info lpsysteminfo
);
Lpsysteminfo is the structure of the returned hardware information.
An example of calling a function is as follows:
#001 //
#002 // obtain the hardware information of the current system.
#003 // Cai junsheng 2007/11/15 QQ: 9073204 Shenzhen
#004 void gethardinfo (void)
#005 {
#006 //
#007 system_info sysinfo;
#008
#009 // obtain system information.
#010: getsysteminfo (& sysinfo );
#011
#012 // display the information of the current system.
#013 //
#014 const int nbufsize = 512;
#015 tchar chbuf [nbufsize];
#016 zeromemory (chbuf, nbufsize );
#017
#018 wsprintf (chbuf, _ T ("oem id: % u/N"), sysinfo. dwoemid );
#019 outputdebugstring (chbuf );
#020
#021 wsprintf (chbuf, _ T ("CPU count: % u/N"), sysinfo. dwnumberofprocessors );
#022 outputdebugstring (chbuf );
#023
#024 wsprintf (chbuf, _ T ("memory paging size: % u/N"), sysinfo. dwpagesize );
#025 outputdebugstring (chbuf );
#026
#027 wsprintf (chbuf, _ T ("CPU type: % u/N"), sysinfo. dwprocessortype );
#028 outputdebugstring (chbuf );
#029
#030 wsprintf (chbuf, _ T ("CPU architecture: % u/N"), sysinfo. wprocessorarchitecture );
#031 outputdebugstring (chbuf );
#032
#033 wsprintf (chbuf, _ T ("CPU level: % u/N"), sysinfo. wprocessorlevel );
#034 outputdebugstring (chbuf );
#035
#036 wsprintf (chbuf, _ T ("CPU version: % u/N"), sysinfo. wprocessorrevision );
#037 outputdebugstring (chbuf );
#038
#039}