#include "winsysteminfo.h"
#include <WinSock2.h>
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <DXGI.h>
#include <vector>
#include <comdef.h>
#include <Wbemidl.h>
#include <string>
#include <QSettings>
#include <QDebug>
#include <QHostInfo>
#include <QBuffer>
#include <QDesktopServices>
#include <QUrl>
#include <QProcess>
#include <QFileInfo>
#include <QDir>
#pragma comment(lib,"DXGI.lib")
#pragma warning(disable: 4996)
#pragma comment(lib, "wbemuuid.lib")
#define _WIN32_DCOM
using namespace std;
//获取操作系统信息
static void GetOsInfo(char * pWindowsVersion,int * pWindowsOSBit)
{
//获取操作系统版本
char WindowsVersion[256] = { 0 };
//获取8.1以上版本操作系统名称
//先判断是否为win8.1或win10
HMODULE hm = NULL;
if (hm = LoadLibrary(TEXT("ntdll.dll")))
{
DWORD dwMajor = 0, dwMinor = 0, dwBuildNumber = 0;
typedef void (WINAPI *getver)(DWORD*, DWORD*, DWORD*);
getver gv = NULL;
gv = (getver)GetProcAddress(hm, "RtlGetNtVersionNumbers");
if (gv)
{
gv(&dwMajor, &dwMinor, &dwBuildNumber);
//printf("Major is %d\nMinor is %d\nOptional Build is %d\n", dwMajor, dwMinor, dwBuildNumber);
if (dwMajor == 6 && dwMinor == 3) //win 8.1
{
sprintf_s(WindowsVersion, "%s", "Windows 8.1");
}
else if (dwMajor == 10 && dwMinor == 0) //win 10
{
sprintf_s(WindowsVersion, "%s", "Windows 10");
}
}
FreeLibrary(hm);
//如果没有输出版本
if (WindowsVersion[0] == 0)
{
//获取8.1以下版本操作系统名称
// get os name according to version number
OSVERSIONINFO osver = { sizeof(OSVERSIONINFO) };
GetVersionEx(&osver);
if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0)
{
sprintf_s(WindowsVersion, "%s", "Windows 2000");
}
else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1)
{
sprintf_s(WindowsVersion, "%s", "Windows XP");
}
else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0)
{
sprintf_s(WindowsVersion, "%s", "Windows 2003");
}
else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2)
{
sprintf_s(WindowsVersion, "%s", "Windows vista");
}
else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1)
{
sprintf_s(WindowsVersion, "%s", "windows 7");
}
else if ((osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) ||
(osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3))
{
sprintf_s(WindowsVersion, "%s", "windows 8");
}
else if ((osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0)
|| (osver.dwMajorVersion == 10))
{
sprintf_s(WindowsVersion, "%s", "windows 10");
}
else
{
sprintf_s(WindowsVersion, "%s", "unkonw");
}
}
}
else
{
sprintf_s(WindowsVersion, "%s", "unkonw");
}
memcpy(pWindowsVersion, WindowsVersion, strlen(WindowsVersion));
pWindowsVersion[strlen(WindowsVersion)] = 0;
//获取操作系统位数
int WindowsOSBit = 0;
SYSTEM_INFO si;
// Copy the hardware information to the SYSTEM_INFO structure.
GetNativeSystemInfo(&si);
// Display the contents of the SYSTEM_INFO structure.
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
{
WindowsOSBit = 64;
}
else
{
WindowsOSBit = 32;
}
*pWindowsOSBit = WindowsOSBit;
//printf("WindowsVersion : %s\n", WindowsVersion);
//printf("osver version : %ld.%ld\n", osver.dwMajorVersion, osver.dwMinorVersion);
//printf("WindowsOSBit : %d\n",WindowsOSBit);
//printf("si.wProcessorArchitecture = %d\nPROCESSOR_ARCHITECTURE_AMD64 = %d\nPROCESSOR_ARCHITECTURE_IA64 = %d\n",
// si.wProcessorArchitecture, PROCESSOR_ARCHITECTURE_AMD64, PROCESSOR_ARCHITECTURE_IA64);
return;
}
//WString转String
std::string WStringToString(const std::wstring &wstr)
{
std::string str(wstr.length(), ' ');
std::copy(wstr.begin(), wstr.end(), str.begin());
return str;
}
//获取显卡信息
int GetGpuInfo(SystemInfo &info, char * pDeviceDescription1, char * pDeviceDescription2, char * pDeviceDescription3, int* pDeviceDescriptionsize)
{
// 参数定义
IDXGIFactory * pFactory;
IDXGIAdapter * pAdapter;
std::vector <IDXGIAdapter*> vAdapters; // 显卡vector
int iAdapterNum = 0; // 显卡的数量
//创建一个DXGI工厂 (必须用CreateDXGIFactory1,如果用CreateDXGIFactory只能取出一块显卡信息)
HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory), (void**)(&pFactory));
if (FAILED(hr))
{
return 0;
}
// 枚举适配器
while (pFactory->EnumAdapters(iAdapterNum, &pAdapter) != DXGI_ERROR_NOT_FOUND)
{
vAdapters.push_back(pAdapter);
++iAdapterNum;
}
*pDeviceDescriptionsize = iAdapterNum;
// 信息输出
info.m_device_info.resize(vAdapters.size());
printf("===============获取到%d块显卡===============\n", iAdapterNum);
for (size_t i = 0; i < vAdapters.size(); i++)
{
// 获取信息
DXGI_ADAPTER_DESC adapterDesc;
vAdapters[i]->GetDesc(&adapterDesc);
std::wstring WDeviceDescription(adapterDesc.Description);
std::string DeviceDescription = WStringToString(WDeviceDescription);
if (i == 0)
{
memcpy(pDeviceDescription1, DeviceDescription.c_str(), DeviceDescription.size());
pDeviceDescription1[DeviceDescription.size()] = 0;
}
if (i == 1)
{
memcpy(pDeviceDescription2, DeviceDescription.c_str(), DeviceDescription.size());
pDeviceDescription2[DeviceDescription.size()] = 0;
}
if (i == 2)
{
memcpy(pDeviceDescription3, DeviceDescription.c_str(), DeviceDescription.size());
pDeviceDescription3[DeviceDescription.size()] = 0;
}
// 输出显卡信息
printf("显卡型号: %s\n", DeviceDescription.c_str());
printf("专用系统内存: %d M\n", adapterDesc.DedicatedSystemMemory / 1024 / 1024);
printf("专用视频内存: %d M\n", adapterDesc.DedicatedVideoMemory / 1024 / 1024);
printf("共享系统内存: %d M\n", adapterDesc.SharedSystemMemory / 1024 / 1024);
// printf("设备描述: %s\n", *fbb);
printf("设备ID: %d\n", adapterDesc.DeviceId);
printf("PCI ID修正版本: %d\n", adapterDesc.Revision);
printf("子系统PIC ID: %d\n", adapterDesc.SubSysId);
printf("厂商编号: %d\n", adapterDesc.VendorId);
printf("\n");
// set SystemInfo struct
info.m_device_info[i].deviceDescription = DeviceDescription;
info.m_device_info[i].dedicatedSystemMemory = adapterDesc.DedicatedSystemMemory / 1024 / 1024;
info.m_device_info[i].dedicatedVideoMemory = adapterDesc.DedicatedVideoMemory / 1024 / 1024;
info.m_device_info[i].sharedSystemMemory = adapterDesc.SharedSystemMemory / 1024 / 1024;
info.m_device_info[i].deviceId = adapterDesc.DeviceId;
info.m_device_info[i].revision = adapterDesc.Revision;
info.m_device_info[i].subSysId = adapterDesc.SubSysId;
info.m_device_inf
没有合适的资源?快使用搜索试试~ 我知道了~
整理windows常用调用函数功能, 具体分如下几类 1: 杀死指定进程,计算昂前进程使用空间 2: 或许系统相关信息(包含gpu cpu 型号, 驱动型号, 系统版本,主机名, 主机uuid等等) 3: 获取某个盘符空间容量, 通过注册表可快速访问相关可移动usb资源, 避免访问网盘导致可能访问过慢问题 4: 系统当前显示语言 5: 唯一性程序启动 6: 加密相关算法
资源推荐
资源详情
资源评论
收起资源包目录
system_helper.7z (15个子文件)
system_helper
winsysteminfo.h 3KB
qaesencryption.h 3KB
trglobal.h 496B
diskspacecheck.h 830B
qaesencryption.cpp 20KB
runguard.cpp 2KB
runguard.h 561B
qtcommon_export.h 420B
trsystem.h 431B
winsysteminfo.cpp 36KB
ezlogger.cpp 3KB
ezutf8.h 652B
trsystem.cpp 1KB
ezlogger.h 492B
diskspacecheck.cpp 5KB
共 15 条
- 1
资源评论
道阻且长,行则降至
- 粉丝: 293
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功