贝贝熊生病了绘本:如何用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);
}