获得电脑的信息 控制台程序

来源:互联网 发布:闲鱼网淘宝 编辑:程序博客网 时间:2024/05/01 07:51
#include <iostream>
#include <windows.h>
using namespace std;


void GetVersionInfo()
{
char szComputerName[MAXBYTE]={0};
char szUserName[MAXBYTE]= {0};
unsigned long nSize  =MAXBYTE;
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
cout<<"电脑的版本为"<<osvi.dwMajorVersion<<"."<<osvi.dwMinorVersion<<endl;
}
else 
{   cout<<"other system"<<endl; }
GetComputerName(szComputerName,&nSize);
cout<<"电脑名字"<<szComputerName<<endl;
GetUserName(szUserName,&nSize);
cout<<"用户名"<<szUserName<<endl;
}
int main()
{
GetVersionInfo();
return 0;
}
0 0
原创粉丝点击