Lấy thông tin ComputerName,CPU,IP,.... C++

Bạn nào biết lấy thông tin về :
Tên HĐH,CPU,RAM,HDD Vender,ComputerName,Workgroup,IP,Proxy,… Bằng C++, Xin chỉ giùm mình với.

1 Like

Bạn nên tìm hiểu trước khi hỏi diễn đàn. Hầu hết code đều có trên mạng. Có code rồi nếu không hiểu quay lại đây hỏi tiếp. Theo mình như vậy sẽ tốt hơn.

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")

void main()
{
   SYSTEM_INFO siSysInfo;
 
   // Copy the hardware information to the SYSTEM_INFO structure. 
 
   GetSystemInfo(&siSysInfo); 
 
   // Display the contents of the SYSTEM_INFO structure. 

   printf("Hardware information: \n");  
   printf("  OEM ID: %u\n", siSysInfo.dwOemId);
   printf("  Number of processors: %u\n", 
      siSysInfo.dwNumberOfProcessors); 
   printf("  Page size: %u\n", siSysInfo.dwPageSize); 
   printf("  Processor type: %u\n", siSysInfo.dwProcessorType); 
   printf("  Minimum application address: %lx\n", 
      siSysInfo.lpMinimumApplicationAddress); 
   printf("  Maximum application address: %lx\n", 
      siSysInfo.lpMaximumApplicationAddress); 
   printf("  Active processor mask: %u\n", 
      siSysInfo.dwActiveProcessorMask); 
}
5 Likes

@ Is2IT ơi nếu có thể thì bạn giải thích luôn các dòng lệnh trong đoạn code trên được không?
Như thế thì thật là tuyệt vời:smiley:

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")

void main()
{
   // SYSTEM_INFO structure that receives the information
   //tạo 1 biến siSysinInfo để lưu thôn tin
   SYSTEM_INFO siSysInfo;
 
   // Copy the hardware information to the SYSTEM_INFO structure. 
   //Nhờ hệ thống lấy thông tin và chứa vào biến siSysInfo

  //Gọi hàm có tên là GetSystemInfo() để truy xuất các thông tin về hệ thống máy tính đang chạy của bạn
   GetSystemInfo(&siSysInfo); 
 
   // Display the contents of the SYSTEM_INFO structure. 
   //  Sau khi lấy được thông tin thì hiển thị thông tin mà hệ thống tìm được qua biến đó.

   printf("Hardware information: \n");  
   printf("  OEM ID: %u\n", siSysInfo.dwOemId); // in ID của nhà SX

   printf("  Number of processors: %u\n", 
      siSysInfo.dwNumberOfProcessors);  // Số Processor

   printf("  Page size: %u\n", siSysInfo.dwPageSize);  //

   printf("  Processor type: %u\n", siSysInfo.dwProcessorType); 

   printf("  Minimum application address: %lx\n", 
      siSysInfo.lpMinimumApplicationAddress);  // Địa chỉ tối thiểu của app

   printf("  Maximum application address: %lx\n", 
      siSysInfo.lpMaximumApplicationAddress); // Địa chỉ tối đa của app

   printf("  Active processor mask: %u\n", 
      siSysInfo.dwActiveProcessorMask); 
}
3 Likes

Hay quá, cảm ơn bạn nhiều nha. :smiley:

2 Likes

Giúp bạn cũng chính là giúp mình nhớ lâu hơn thôi mà. :sunny:

3 Likes

Đây là kết quả mà mình chạy trên Win 8.1.

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?