打算练习Socket的时候用用,最近有点小事情,没时间继续完善,先把写的这些代码贴上来,有空了再完善一下。
HardwareInfo.h
1 #include <stdio.h> 2 #include <windows.h> 3 #include <vfw.h> 4 5 #pragma comment(lib,"Vfw32.lib") 6 #pragma comment(lib,"winmm.lib") 7 #ifndef VER_NT_WORKSTATION 8 #define VER_NT_WORKSTATION 1 9 #endif 10 11 /* 12 // vc6.0需定义 13 typedef struct _MEMORYSTATUSEX { 14 DWORD dwLength; // 结构体数据大小 sizeof(_MEMORYSTATUSEX) 15 DWORD dwMemoryLoad; // 内存使用率 16 LONGLONG ullTotalPhys; // 物理内存总大小(单位:字节) 17 LONGLONG ullAvailPhys; // 物理内存可用大小(单位:字节) 18 LONGLONG ullTotalPageFile; // 总页面大小(物理内存总大小+硬盘划分的虚拟内存总大小)(单位:字节) 19 LONGLONG ullAvailPageFile; // 当前进程能获取的最大内存数(单位:字节) 20 LONGLONG ullTotalVirtual; // 当前进程最大内存寻址地址(默认2GB,开启大地址后就是4GB) 21 LONGLONG ullAvailVirtual; // 当前进程可用最大内存(单位:字节) 22 LONGLONG ullAvailExtendedVirtual; 23 } MEMORYSTATUSEX, *LPMEMORYSTATUSEX; 24 */ 25 typedef struct _OSVERSIONINFOEXA1 { 26 DWORD dwOSVersionInfoSize; 27 DWORD dwMajorVersion; 28 DWORD dwMinorVersion; 29 DWORD dwBuildNumber; 30 DWORD dwPlatformId; 31 CHAR szCSDVersion[128]; 32 WORD wServicePackMajor; 33 WORD wServicePackMinor; 34 WORD wSuiteMask; 35 BYTE wProductType; 36 BYTE wReserved; 37 } OSVERSIONINFOEXA1, *POSVERSIONINFOEXA1, *LPOSVERSIONINFOEXA1; 38 39 40 /* 41 屏幕截图 42 lpData:存放截图数据指针 43 hWnd :目标窗口,默认为桌面 44 成功返回截图数据大小,失败返回0. 45 */ 46 DWORD PrtScr(PCHAR *lpData, HWND hWnd = 0); 47 48 /* 49 是否有摄像头 50 有摄像头返回TRUE,否则返回FALSE 51 */ 52 BOOL HaveCameras(void); 53 54 /* 55 获取CPU名称 56 成功返回CPU名称,失败返回NULL(VS2013不支持Debug模式下获取) 57 */ 58 LPSTR GetCPUName(void); 59 60 /* 61 获取CPU制造商 62 成功返回CPU制造商,失败返回NULL(VS2013不支持Debug模式下获取) 63 */ 64 LPSTR GetCPUManufacturer(void); 65 66 /* 67 获取声卡名字 68 成功返回声卡名字,失败返回NULL 69 */ 70 LPSTR GetSoundCarName(void); 71 72 /* 73 获取磁盘容量信息 74 diskPath:盘符 75 used:已用空间 76 freed:剩余空间 77 total:总空间 78 成功返回TRUE,失败返回FALSE 79 */ 80 BOOL GetDiskSpaceInfo(LPSTR diskPath, float *used, float *freed, float *total); 81 82 /* 83 获取运行内存总额 84 返回运存总额 85 */ 86 FLOAT GetSysRam(void); 87 88 /* 89 获取运存已用比例 90 返回运存已用比例 91 */ 92 DWORD GetRamProportion(void); 93 94 /* 95 获取系统启动时间 96 返回格式化文本字符串 97 */ 98 LPSTR GetSysStartTime(void); 99 100 /* 101 获取系统信息 102 dwMajor:高版本位 103 dwMinjor:低版本位 104 bDesc:是否获取系统描述 105 bBit:是否获取位数 106 bSPVer:是否获取系统补丁包版本 107 bBuildVer:是否获取内部版本 108 成功返回系统信息字符串,失败返回NULL 109 */ 110 LPSTR GetSysInfo(DWORD *dwMajor = NULL, DWORD *dwMinjor = NULL, BOOL bDesc = FALSE, BOOL bBit = FALSE, BOOL bSPVer = FALSE, BOOL bBuildVer = FALSE);
HardwareInfo.cpp
1 #include "HardwareInfo.h" 2 3 int main(void) 4 { 5 6 LPSTR lpCPUName = GetCPUName(); 7 LPSTR lpCPUManu = GetCPUManufacturer(); 8 LPSTR lpSoundCarName = GetSoundCarName(); 9 printf("处理器: %s\n\n", lpCPUName); 10 printf("CPU制造商: %s\n\n", lpCPUManu); 11 printf("声卡: %s\n\n", lpSoundCarName); 12 float used, usable, total; 13 GetDiskSpaceInfo("D:", &used, &usable, &total); 14 printf("D盘 已用: %.1fG, 可用:%.1fG, 总大小:%.1fG\n\n", used, usable, total); 15 printf("运行内存: %.1fG, 已用%d%%\n\n", GetSysRam(), GetRamProportion()); 16 LPSTR lpStartTime = GetSysStartTime(); 17 printf("已开机: %s\n\n", GetSysStartTime()); 18 LPSTR lpSysVer = GetSysInfo(0, 0, 1, 1, 1); 19 printf("系统版本: %s\n\n", lpSysVer); 20 free(lpCPUName); 21 free(lpCPUManu); 22 free(lpSoundCarName); 23 free(lpStartTime); 24 free(lpSysVer); 25 26 Sleep(1000); 27 DWORD dwLen = 0; 28 char *lpData = NULL; 29 30 dwLen = PrtScr(&lpData); 31 FILE *wj = NULL; 32 fopen_s(&wj, "c:\\1.bmp", "wb"); 33 fwrite(lpData, dwLen, 1, wj); 34 fclose(wj); 35 free(lpData); 36 system("c:\\1.bmp"); 37 system("pause"); 38 return 0; 39 } 40 41 DWORD PrtScr(PCHAR *lpData, HWND hWnd) 42 { 43 HDC hdcScreen, hdcMem; 44 RECT rc = { 0 }, desRc = { 0 }; 45 HBITMAP hbmScreen = NULL; 46 BITMAP bmpScreen = { 0 }; 47 BITMAPINFOHEADER bitInfo = { 0 }; 48 BITMAPFILEHEADER bitHead = { 0 }; 49 DWORD dwBmpSize, dwSizeofDIB; 50 char *lpbitmap = NULL; 51 int width, height; 52 53 if (!hWnd) 54 hWnd = GetDesktopWindow(); 55 GetWindowRect(hWnd, &rc); 56 GetWindowRect(GetDesktopWindow(), &desRc); 57 58 hdcScreen = GetDC(NULL); 59 hdcMem = CreateCompatibleDC(hdcScreen); 60 if (!hdcMem) 61 return 0; 62 hbmScreen = CreateCompatibleBitmap(hdcScreen, rc.right - rc.left, rc.bottom - rc.top); 63 if (!hbmScreen) 64 return 0; 65 SelectObject(hdcMem, hbmScreen); 66 width = (rc.right > desRc.right) ? (desRc.right - rc.left) : (rc.right - rc.left); 67 height = (rc.bottom > desRc.bottom) ? (desRc.bottom - rc.top) : (rc.bottom - rc.top); 68 if (!BitBlt(hdcMem, 0, 0, width, height, hdcScreen, rc.left, rc.top, SRCCOPY)) 69 return 0; 70 GetObject(hbmScreen, sizeof(BITMAP), &bmpScreen); 71 72 bitInfo.biSize = sizeof(BITMAPINFOHEADER); 73 bitInfo.biWidth = width; 74 bitInfo.biHeight = height; 75 bitInfo.biPlanes = 1; 76 bitInfo.biBitCount = 32; 77 bitInfo.biCompression = BI_RGB; 78 79 dwBmpSize = ((bmpScreen.bmWidth * bitInfo.biBitCount + 31) / 32) * 4 * bmpScreen.bmHeight; 80 lpbitmap = (char *)malloc(dwBmpSize); 81 if (!lpbitmap) 82 return 0; 83 GetDIBits(hdcScreen, hbmScreen, 0, (UINT)bmpScreen.bmHeight, lpbitmap, (BITMAPINFO *)&bitInfo, DIB_RGB_COLORS); 84 85 dwSizeofDIB = dwBmpSize + sizeof(bitHead)+sizeof(bitInfo); 86 bitHead.bfOffBits = (DWORD)sizeof(bitHead)+(DWORD)sizeof(bitInfo); 87 bitHead.bfSize = dwSizeofDIB; 88 // 必须是字符BM或者十六进制代替0x4D42="BM" 89 bitHead.bfType = MAKEWORD(‘B‘, ‘M‘); 90 91 *lpData = (char *)malloc(dwSizeofDIB); 92 if (!*lpData) 93 return 0; 94 memmove(*lpData, &bitHead, sizeof(bitHead)); 95 memmove(*lpData + sizeof(bitHead), &bitInfo, sizeof(bitInfo)); 96 memmove(*lpData + sizeof(bitHead)+sizeof(bitInfo), lpbitmap, dwBmpSize); 97 free(lpbitmap); 98 DeleteObject(hbmScreen); 99 DeleteObject(hdcMem); 100 ReleaseDC(NULL, hdcScreen); 101 return dwSizeofDIB; 102 } 103 104 BOOL HaveCameras(void) 105 { 106 char ver[256] = { 0 }, name[256] = { 0 }; 107 UINT num = 0; 108 109 do 110 { 111 memset(name, 0, 256); 112 if (capGetDriverDescription(num, name, 100, ver, 100)) 113 { 114 num++; 115 } 116 } while (lstrlen(name)); 117 return (num ? TRUE : FALSE); 118 } 119 120 LPSTR GetCPUName(void) 121 { 122 LPSTR lpName = (LPSTR)malloc(100); 123 memset(lpName, 0, 100); 124 125 __asm{ 126 PUSHAD 127 MOV EAX, 0x80000002 128 CPUID 129 MOV ESI, [EBP - 0x4] 130 MOV SS : [ESI], EAX 131 MOV SS : [ESI + 0x4], EBX 132 MOV SS : [ESI + 0x8], ECX 133 MOV SS : [ESI + 0xC], EDX 134 MOV EAX, 0x80000003 135 CPUID 136 MOV SS : [ESI + 0x10], EAX 137 MOV SS : [ESI + 0x14], EBX 138 MOV SS : [ESI + 0x18], ECX 139 MOV SS : [ESI + 0x1C], EDX 140 MOV EAX, 0x80000004 141 CPUID 142 MOV SS : [ESI + 0x20], EAX 143 MOV SS : [ESI + 0x24], EBX 144 MOV SS : [ESI + 0x28], ECX 145 MOV SS : [ESI + 0x2C], EDX 146 POPAD 147 } 148 return lpName; 149 } 150 151 LPSTR GetCPUManufacturer(void) 152 { 153 LPSTR lpStr = (LPSTR)malloc(20); 154 memset(lpStr, 0, 20); 155 156 __asm{ 157 PUSHAD 158 XOR EAX, EAX 159 CPUID 160 MOV EAX, DWORD PTR SS : [EBP - 0x4] 161 MOV DWORD PTR SS : [EAX], EBX 162 MOV DWORD PTR SS : [EAX + 0x4], EDX 163 MOV DWORD PTR SS : [EAX + 0x8], ECX 164 POPAD 165 } 166 167 if (!lstrcmp("GenuineIntel", lpStr)) 168 memmove(lpStr, "Intel Corporation.", 20); 169 else if (!lstrcmp("AuthenticAMD", lpStr)) 170 memmove(lpStr, "Advanced Micro Devices.", 20); 171 else if (!lstrcmp("AMD ISBETTER", lpStr)) 172 memmove(lpStr, "Advanced Micro Devices.", 20); 173 else if (!lstrcmp("Geode By NSC", lpStr)) 174 memmove(lpStr, "National Semiconductor.", 20); 175 else if (!lstrcmp("CyrixInstead", lpStr)) 176 memmove(lpStr, "Cyrix Corp., VIA Inc.", 20); 177 else if (!lstrcmp("NexGenDriven", lpStr)) 178 memmove(lpStr, "NexGen Inc., Advanced Micro Devices.", 20); 179 else if (!lstrcmp("CentaurHauls", lpStr)) 180 memmove(lpStr, "IDT\\Centaur, Via Inc.", 20); 181 else if (!lstrcmp("UMC UMC UMC ", lpStr)) 182 memmove(lpStr, "United Microelectronics Corp.", 20); 183 else if (!lstrcmp("RiseRiseRise", lpStr)) 184 memmove(lpStr, "Rise.", 20); 185 else if (!lstrcmp("GenuineTMx86", lpStr)) 186 memmove(lpStr, "Transmeta.", 20); 187 else if (!lstrcmp("TransmetaCPU", lpStr)) 188 memmove(lpStr, "Transmeta.", 20); 189 else 190 memmove(lpStr, "Unknown Manufacturer.", 20); 191 192 return lpStr; 193 } 194 195 LPSTR GetSoundCarName(void) 196 { 197 WAVEOUTCAPS wav = { 0 }; 198 LPSTR lpName = (LPSTR)malloc(50); 199 200 waveOutGetDevCaps(0, &wav, sizeof(wav)); 201 202 // 有点电脑获取的数据不完整,缺失 " Audio)",为了美观获取不到的手动加入 203 if (wav.szPname[lstrlen(wav.szPname)-1] != ‘)‘) 204 sprintf_s(lpName, 50, "%s Audio)", wav.szPname); 205 else 206 sprintf_s(lpName, 50, "%s", wav.szPname); 207 return lpName; 208 } 209 210 BOOL GetDiskSpaceInfo(LPSTR diskPath, float *used, float *freed, float *total) 211 { 212 ULARGE_INTEGER a1, b1, c1; 213 LONGLONG a, b, c; 214 float v1, v2, v3; 215 if (!GetDiskFreeSpaceEx(diskPath, &a1, &b1, &c1)) 216 return FALSE; 217 218 a = (LONGLONG)a1.QuadPart; 219 b = (LONGLONG)b1.QuadPart; 220 c = (LONGLONG)c1.QuadPart; 221 c = b - a; 222 223 v1 = (float)(a / (1024 * 1024 * 1024.0)); 224 v2 = (float)(b / (1024 * 1024 * 1024.0)); 225 v3 = (float)(c / (1024 * 1024 * 1024.0)); 226 227 memmove(used, &v3, sizeof(float)); 228 memmove(freed, &v1, sizeof(float)); 229 memmove(total, &v2, sizeof(float)); 230 231 return TRUE; 232 } 233 234 FLOAT GetSysRam(void) 235 { 236 typedef BOOL(WINAPI *func)(LPMEMORYSTATUSEX); 237 MEMORYSTATUSEX stMem = { 0 }; 238 239 func GlobalMemoryStatusEx = (func)GetProcAddress(LoadLibrary("Kernel32.dll"), "GlobalMemoryStatusEx"); 240 stMem.dwLength = sizeof(stMem); 241 GlobalMemoryStatusEx(&stMem); 242 return (FLOAT)(stMem.ullTotalPhys / (1024 * 1024 * 1024.0)); 243 } 244 245 DWORD GetRamProportion(void) 246 { 247 typedef BOOL(WINAPI *func)(LPMEMORYSTATUSEX); 248 MEMORYSTATUSEX stMem = { 0 }; 249 250 func GlobalMemoryStatusEx = (func)GetProcAddress(LoadLibrary("Kernel32.dll"), "GlobalMemoryStatusEx"); 251 stMem.dwLength = sizeof(stMem); 252 GlobalMemoryStatusEx(&stMem); 253 return stMem.dwMemoryLoad; 254 } 255 256 LPSTR GetSysStartTime(void) 257 { 258 LPSTR lpStr = (LPSTR)malloc(sizeof(char)* 50); 259 DWORD dwStart = GetTickCount(); 260 DWORD day, hou, min, sec; 261 262 day = dwStart / (1000 * 60 * 60 * 24); 263 hou = dwStart / (1000 * 60 * 60) - day * 24; 264 min = dwStart / (1000 * 60) - day * 24 * 60 - hou * 60; 265 sec = dwStart / (1000) - day * 24 * 60 * 60 - hou * 60 * 60 - min * 60; 266 267 sprintf_s(lpStr, 50, "%d天%d小时%d分钟%d秒", day, hou, min, sec); 268 return lpStr; 269 } 270 271 LPSTR GetSysInfo(DWORD *dwMajor, DWORD *dwMinjor, BOOL bDesc, BOOL bBit, BOOL bSPVer, BOOL bBuildVer) 272 { 273 OSVERSIONINFOEXA1 osvi = { 0 }; 274 SYSTEM_INFO si = { 0 }; 275 BOOL bWow64 = FALSE; 276 DWORD dwType = 0, dwBuild = 0; 277 char strSys[100] = { 0 }, strVer[20] = { 0 }; 278 279 osvi.dwOSVersionInfoSize = sizeof(osvi); 280 typedef BOOL(WINAPI *fun)(LPOSVERSIONINFOEXA1); 281 fun GetVersionEx1 = (fun)GetProcAddress(LoadLibrary("Kernel32.dll"), "GetVersionExA"); 282 if (GetVersionEx1(&osvi)) 283 { 284 dwBuild = osvi.dwBuildNumber; 285 GetSystemInfo(&si); 286 287 typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); 288 LPFN_ISWOW64PROCESS IsWow64Process1 = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process"); 289 IsWow64Process1((void *)-1, &bWow64); 290 291 typedef void (WINAPI *func)(DWORD *, DWORD *, DWORD *); 292 func RtlGetNtVersionNumbers = (func)GetProcAddress(LoadLibrary("ntdll.dll"), "RtlGetNtVersionNumbers"); 293 RtlGetNtVersionNumbers(&osvi.dwMajorVersion, &osvi.dwMinorVersion, &osvi.dwBuildNumber); 294 295 if (dwMajor) 296 *dwMajor = osvi.dwMajorVersion; 297 if (dwMinjor) 298 *dwMinjor = osvi.dwMinorVersion; 299 300 if (osvi.dwMajorVersion == 10) 301 { 302 if (osvi.dwMinorVersion == 0) 303 { 304 lstrcpyn(strSys, (osvi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016"), 100); 305 } 306 } 307 else if (osvi.dwMajorVersion == 6) 308 { 309 if (osvi.dwMinorVersion == 0) 310 { 311 lstrcpyn(strSys, (osvi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008"), 100); 312 } 313 else if (osvi.dwMinorVersion == 1) 314 { 315 lstrcpyn(strSys, (osvi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2"), 100); 316 } 317 else if (osvi.dwMinorVersion == 2) 318 { 319 lstrcpyn(strSys, (osvi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012"), 100); 320 } 321 else if (osvi.dwMinorVersion == 3) 322 { 323 lstrcpyn(strSys, (osvi.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2"), 100); 324 } 325 } 326 else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) 327 { 328 lstrcpyn(strSys, "Windows 2000", 100); 329 if (osvi.wProductType == 1) 330 { 331 lstrcpyn(strVer, "Professional", 20); 332 } 333 else if ((osvi.wSuiteMask & 128) == 0) 334 { 335 lstrcpyn(strVer, "Datacenter Server", 20); 336 } 337 else if ((osvi.wSuiteMask & 2) == 0) 338 { 339 lstrcpyn(strVer, "Advanced Server", 20); 340 } 341 else 342 { 343 lstrcpyn(strVer, "Server", 20); 344 } 345 } 346 else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) 347 { 348 lstrcpyn(strSys, "Windows XP", 100); 349 if ((osvi.wSuiteMask & 512) == 1) 350 { 351 lstrcpyn(strVer, "Home Edition", 20); // 家庭版 352 } 353 else 354 { 355 lstrcpyn(strVer, "Professional", 20); // 专业版 356 } 357 } 358 else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) 359 { 360 if (GetSystemMetrics(89) != 0) 361 { 362 lstrcpyn(strSys, "Windows Server 2003 R2, ", 100); 363 } 364 else if ((osvi.wSuiteMask & 8192) == 8192) 365 { 366 lstrcpyn(strSys, "Windows Storage Server 2003", 100); 367 } 368 else if ((osvi.wSuiteMask & 32768) == 32768) 369 { 370 lstrcpyn(strSys, "Windows Home Server", 100); 371 } 372 else if (osvi.wProductType == 1 && si.wProcessorArchitecture == 9) 373 { 374 lstrcpyn(strSys, "Windows XP Professional x64 Edition", 100); // XP专业版64位系统 375 } 376 else 377 { 378 lstrcpyn(strSys, "Windows Server 2003, ", 100); 379 } 380 } 381 else if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) 382 { 383 lstrcpyn(strSys, "Windows 98", 100); 384 } 385 else if (osvi.dwMajorVersion >= 6) 386 { 387 typedef BOOL(WINAPI *pGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD); 388 pGetProductInfo RtlGetProductInfo = (pGetProductInfo)GetProcAddress(LoadLibrary("Kernel32.dll"), "RtlGetProductInfo"); 389 RtlGetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType); 390 391 switch (dwType) 392 { 393 case 1: // 旗舰版 394 lstrcpyn(strVer, "Ultimate Edition", 20); 395 break; 396 case 2: // 家庭普通版 397 lstrcpyn(strVer, "Home Basic Edition", 20); 398 break; 399 case 3: // 家庭高级版 400 lstrcpyn(strVer, "Home Premiu Edition", 20); 401 break; 402 case 4: // 企业版 403 lstrcpyn(strVer, "Enterprise Edition", 20); 404 break; 405 case 6: // 商业版 406 lstrcpyn(strVer, "Business Edition", 20); 407 break; 408 case 7: // 服务器标准版 409 lstrcpyn(strVer, "Standard", 20); 410 break; 411 case 8: // 服务器企业版 412 lstrcpyn(strVer, "Datacenter Edition", 20); 413 break; 414 case 9: // 小型服务器 415 lstrcpyn(strVer, "Small Business Server", 20); 416 break; 417 case 10: // 服务器企业版(完整的安装) 418 lstrcpyn(strVer, "Enterprise Edition", 20); 419 break; 420 case 11: // 入门版 421 lstrcpyn(strVer, "Starter Edition", 20); 422 break; 423 case 12: // 服务器数据中心版(核心安装) 424 lstrcpyn(strVer, "Datacenter Edition (core installation)", 20); 425 break; 426 case 13: // 服务器标准版(核心安装) 427 lstrcpyn(strVer, "Standard Edition (core installation)", 20); 428 break; 429 case 14: // 服务器企业版(核心安装) 430 lstrcpyn(strVer, "Enterprise Edition (core installation)", 20); 431 break; 432 case 15: // 一个企业级的平台 433 lstrcpyn(strVer, "Enterprise Edition for Itanium-based Systems", 20); 434 break; 435 case 16: // 商用公司版 436 lstrcpyn(strVer, "Business N", 20); 437 break; 438 case 17: // Web服务器(完整安装) 439 lstrcpyn(strVer, "Web Server (full installation)", 20); 440 break; 441 case 18: // 服务器群集版 442 lstrcpyn(strVer, "HPC Edition", 20); 443 break; 444 case 19: // 2008 R2 储存服务器版 445 lstrcpyn(strVer, "Windows Storage Server 2008 R2 Essentials", 20); 446 break; 447 case 20: // 服务器快速储存版 448 lstrcpyn(strVer, "Storage Server Express", 20); 449 break; 450 case 21: // 服务器标准储存版 451 lstrcpyn(strVer, "Storage Server Standard", 20); 452 break; 453 case 22: // 服务器储存组 454 lstrcpyn(strVer, "Storage Server Workgroup", 20); 455 break; 456 case 23: // 服务器储存企业版 457 lstrcpyn(strVer, "Storage Server Enterprise", 20); 458 break; 459 case 25: // 小型商业服务器 460 lstrcpyn(strVer, "Small Business Server Premium Edition", 20); 461 break; 462 case 48: // 专业版 463 lstrcpyn(strVer, "Professional", 20); 464 break; 465 } 466 } 467 } 468 if (lstrlen(strSys) < 2) 469 { 470 sprintf_s(strSys, 100, "获取失败,请检查版本:%d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); 471 return NULL; 472 } 473 else 474 { 475 LPSTR lpStr = (LPSTR)malloc(sizeof(char)* 100); 476 477 lstrcpyn(lpStr, strSys, lstrlenA(strSys) + 1); 478 if (bDesc) 479 { 480 lstrcatA(lpStr, " "); 481 lstrcatA(lpStr, strVer); 482 } 483 if (bBit) 484 lstrcatA(lpStr, (bWow64 ? " x64 " : " x86 ")); 485 if (bSPVer) 486 lstrcatA(lpStr, (LPCSTR)&osvi.szCSDVersion); 487 if (bBuildVer) 488 sprintf_s(lpStr,100, "%s,Build:%d", lpStr, dwBuild); 489 return lpStr; 490 } 491 return NULL; 492 }
效果图
原文地址:https://www.cnblogs.com/biaoge140/p/9749169.html
时间: 2024-10-07 22:31:10