得到电脑的信息

王朝vc·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

这里有几个函数,用来得到机器的信息:

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;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航