甄嬛传琪嫔的下场集数:如何用VC代码获得本地计算机信息?

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 09:10:33
在“我的电脑”里,右键单击鼠标,点“属性”,出现的窗口里显示的那些计算机信息(如内存、CPU等)怎么用VC++代码获得??

你的问题可以这样的解决,但是在解决问题之前你必须了解

几个windows api函数,它们是:

1:void GetSystemInfo(
LPSYSTEM_INFO lpSystemInfo
);

Parameters lpSystemInfo

2:void GlobalMemoryStatus(
LPMEMORYSTATUS lpBuffer
);

Parameters lpBuffer

我写了一部分的代码,希望对你会有用处:

void CMemView::OnDraw(CDC* pDC)
{
CMemDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

//得到关于内存的信息,
int DIV=1024;
char *divisor = "K";
MEMORYSTATUS stat;//它的成员变量非常的多,我只是写了几个,你需要补齐它们

GlobalMemoryStatus (&stat);
CString str;
str.Format("The MemoryStatus structure is %ld bytes long.\n",stat.dwLength);

pDC->TextOut(10,10,str);

str.Format("There are %*ld total %sbytes of physical memory.\n",7, stat.dwTotalPhys/DIV, divisor);

pDC->TextOut(10,30,str);

str.Format("There are %*ld free %sbytes of physical memory.\n",7, stat.dwAvailPhys/DIV, divisor);
pDC->TextOut(10,50,str);

下面的代码可以得到系统的一些信息,不过你要了解一下LPSYSTEM_INFO结构的变量
//LPSYSTEM_INFO sysinfo;
//GetSystemInfo(sysinfo);
}