VC语言

本类阅读TOP10

·VC++ 学习笔记(二)
·用Visual C++打造IE浏览器(1)
·每个开发人员现在应该下载的十种必备工具
·教你用VC6做QQ对对碰外挂程序
·Netmsg 局域网聊天程序
·Windows消息大全
·VC++下使用ADO编写数据库程序
·VC++学习笔记(四)
·非法探取密码的原理及其防范
·怎样在VC++中访问、修改注册表

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
得到电脑的信息

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

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

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;
}




相关文章

相关软件