文件名称:QT读取系统信息--磁盘管理器
文件大小:2KB
文件格式:TXT
更新时间:2012-10-26 12:51:07
系统信息
char cmd[100] = "free -m"; FILE * f = popen(cmd,"r"); char prt[100]; QString str; QStringList str2; int total,used; fgets(prt,100,f); fgets(prt,100,f); printf("%s",prt); str.append(prt); str2 = str.split(" ",QString::SkipEmptyParts); total = str2.at(1).toInt(); used = str2.at(2).toInt(); QString str3(QString("total Memory : ") + QString::number(total) + "MB"); m_ui->label_4->setText(str3); double per = (used - 0.0)/total; m_ui->progressBar_2->setValue(per * 100); pclose(f);//内存查询完毕 memset(cmd,100,'0'); str = ""; str2.clear(); total = used = 0;//数据初始化 strcpy(cmd ,"df -hT"); f = popen(cmd,"r"); int length;