#include <stdio.h>
#include <sys/utsname.h>
#include <sys/sysinfo.h>
using namespace std;
class info_Name
{
private:
char *my_File;
char *os_Machine,*os_Version,*os_Release,*os_Name;
double free_Ram,total_Ram;
struct utsname my_Os;
struct sysinfo my_RAM;
public:
info_Name(char *file_Name)
{
my_File=file_Name;
uname(&my_Os);
sysinfo(&my_RAM);
os_Name=my_Os.sysname;
os_Release=my_Os.release;
os_Version=my_Os.version;
os_Machine=my_Os.machine;
total_Ram=my_RAM.totalram/(1024.*1024.);
free_Ram=my_RAM.freeram/(1024.*1024.);
}
void Save()
{
FILE* save_File;
save_File=fopen(my_File,"wt");
fprintf(save_File,"%f\n",total_Ram);
fprintf(save_File,"%f\n",free_Ram);
fprintf(save_File,"%s\n",os_Name);
fprintf(save_File,"%s\n",os_Release);
fprintf(save_File,"%s\n",os_Version);
fprintf(save_File,"%s\n",os_Machine);
fclose(save_File);
}
};
int main(int argc, char **argv)
{
info_Name my_Version("version.txt");
my_Version.Save();
return 0;
}
Brak komentarzy:
Prześlij komentarz