这里有几个函数,用来得到机器的信息:
1、得到注册表键值:这里判断norton的病毒库版本
void CInfoshowDlg::GetNortonVersion()
{
HKEY hkey;
LONG result = RegOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\INTEL\\LANDesk\\VirusProtect6\\CurrentVersion",&hkey);
if (result != 0)
{
AfxMessageBox("无法打开注册表键值!");
return ;
}
DWORD datalen,type;
BYTE data[80];
result = RegQueryValueEx(hkey,"PatternFileDate",NULL,&type,data,&datalen);
if (result != 0)
{
AfxMessageBox("无法读取相应值!");
RegCloseKey(hkey);
return ;
}
char tmp;
int years,months,days;
tmp = data[0];
years = tmp%10;
tmp = data[1];
months = tmp + 1;
tmp = data[2];
days = tmp;
m_norton_version.Format("200%d.%d.%d",years,months,days);
RegCloseKey(hkey);
}
2、硬盘空间:
CString CInfoshowDlg::GetDisk(char *disk)
{
_ULARGE_INTEGER result_freespace,result_totalspace,result_g;
CString disk_space;
int error = 0;
int free_space,total_space;
int free_percent;
/* Get free space */
GetDiskFreeSpaceEx(disk,&result_freespace,&result_totalspace,&result_g);
if (error != 0)
{
CString t;
t.Format("GetDiskFreeSpace() error=%d",error);
AfxMessageBox(t);
}
free_space = result_freespace.QuadPart/1024/1024;
total_space = result_totalspace.QuadPart/1024/1024;
free_percent = (float)free_space/total_space*100;
disk_space.Format("%dM/ %dM (%d%%)",free_space,total_space,free_percent);
return disk_space;
}
本文地址:http://com.8s8s.com/it/it500.htm