现在的位置: 首页 > 综合 > 正文

在 研究完成端口时 遇到 GetSystemInfo 做下记录

2013年10月11日 ⁄ 综合 ⁄ 共 1456字 ⁄ 字号 评论关闭
有一次,我正在开发一个视频压缩程序,而压缩算法是需要非常高效的,也就是需要使用到
CPU
的多媒体指令。在
X86
的领域里,目前主要有两家
CPU
,就是
INTEL

AMD
。它们的多媒体指令是不一样的。为了区分这种不同的指令,就需要调用函数
GetSystemInfo
来获取
CPU
的信息,然后再调用不同的动态连接库来进行多媒体数据压缩。
 
函数
GetSystemInfo
声明如下:
 
WINBASEAPI
VOID
WINAPI
GetSystemInfo(
    __out LPSYSTEM_INFO lpSystemInfo
    );
 
lpSystemInfo


是返回硬件信息的结构。
 
调用函数的例子如下:
#001 //
#002  //
获取当前系统的硬件信息。
#003  //
蔡军生
 2007/11/15 QQ:9073204
深圳
#004  void GetHardInfo(void)
#005  {
#006         //
#007         SYSTEM_INFO sysInfo;
#008        
#009         //
获取系统的信息。
#010         ::GetSystemInfo(&sysInfo);
#011        
#012         //
显示当前系统的信息。
#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
个数
: %u/n"),sysInfo.dwNumberOfProcessors);
#022         OutputDebugString(chBuf);
#023 
#024         wsprintf(chBuf,_T("
内存分页大小
: %u/n"),sysInfo.dwPageSize);
#025         OutputDebugString(chBuf);
#026 
#027         wsprintf(chBuf,_T("CPU
类型
: %u/n"),sysInfo.dwProcessorType);
#028         OutputDebugString(chBuf);
#029 
#030         wsprintf(chBuf,_T("CPU
架构
: %u/n"),sysInfo.wProcessorArchitecture);
#031         OutputDebugString(chBuf);
#032 
#033         wsprintf(chBuf,_T("CPU
的级别
: %u/n"),sysInfo.wProcessorLevel);
#034         OutputDebugString(chBuf);
#035 
#036         wsprintf(chBuf,_T("CPU
的版本
: %u/n"),sysInfo.wProcessorRevision);
#037         OutputDebugString(chBuf);
#038 
#039  }
#040

抱歉!评论已关闭.