- [C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform
- [C#] Hướng dẫn viết ứng dụng chat với Gemini AI Google Winform
- Hướng dẫn khóa file bằng nhiều process id, không cho xóa tập tin
- Hướng dẫn cách tạo Product Id cho ứng dụng phần mềm XXXXX-XXXXX-XXXXX-XXXXX
- [SQLSERVER] Hướng dẫn tạo script sql từ ứng dụng Sqlserver management Studio
- [C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform
- [VB.NET] Hướng dẫn lấy thông tin tài khoản đăng nhập windows và khởi động lại ứng dụng ở chế độ Administrator
- [C#] Sử dụng thư viện Polly gửi lại request api khi request bị lỗi hay rớt mạng
- [DEVEXPRESS] Chia sẻ source code tạo báo cáo report in tem nhãn label trên C# winform
- [DEVEXPRESS] Hướng dẫn vẽ biểu đồ Bar Chart trên Winform
- [C#] Tạo form đăng nhập và đăng ký với hiệu ứng Sliding Animation Effect
- [C#] Hướng dẫn tạo thanh toán đơn hàng qua mã vạch VietQR sử dụng API PayOS hoàn toàn miễn phí
- [C#] Hướng dẫn ghi log ra RichTextBox giống Console trên Winform sử dụng thư viện Serilog
- [C#] Hướng dẫn cách tạo mã QR Code trên file Excel
- [VB.NET] Gởi tin nhắn và file đính kèm qua ứng dụng gởi tin nhắn Whats App
- [C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
- [TOOL] Chia sẻ phần mềm thay đổi thông tin cấu hình máy tính
- [C#] Hướng dẫn Export dữ liệu ra file Microsoft Word Template
- [C#] Chia sẻ source code tool kiểm tra domain website
- [C#] Hướng dẫn tạo file PDF sử dụng thư viện QuestPDF
[C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
Xin chào các bạn, bài viết hôm nay mình sẽ chia sẽ đến các bạn class SystemInfoHelper.cs
, dùng để lấy cấu hình thông tin phần cứng máy tính xuất ra text file trong lập trình c#, winform.
[C#] Get system info to text file
Kiểm tra cấu hình laptop, máy tính là việc làm cần thiết khi bạn muốn biết chính xác các phần cứng được trang bị trên máy.
Để kiểm tra thông tin cấu hình máy tính Windows bạn có thể dùng lệnh dxdiag trên cmd, xem qua Properties của PC hoặc dùng phần mềm hỗ trợ.
Trong bài viết dưới đây, mình sẽ hướng dẫn các bạn những cách kiểm tra, xem cấu hình phần cứng trên máy tính nhanh chóng, đơn giản nhất nhưng vẫn đảm bảo cung cấp đủ thông tin máy tính cần thiết, có thể thực hiện được cả trên Windows 10, 8/8.1, Windows 7, XP.
Với class này, các bạn sẽ dễ dàng lấy cấu hình phần cứng của máy Client xuất ra Text File, rồi có thể gởi file text này về Server chẳng hạn.
Giao diện demo ứng dụng lấy thông tin cấu hình ra Text File C#:
Class SystemInfoHelper.cs rất dài, nên các bạn download ở dưới source code bài viết của mình nhé.
Code Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace systeminfo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private const int WM_SYSCOMMAND = 274; private const int SC_MAXIMIZE = 61488;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private async void btnGetsystemInfo_Click(object sender, EventArgs e)
{
btnGetsystemInfo.Text = "Please waiting...";
btnGetsystemInfo.Enabled = false;
await SystemInfoHelper.WriteFileText("info.txt");
ProcessStartInfo startInfo = new ProcessStartInfo("notepad.exe", "info.txt");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
var proc = Process.Start(startInfo);
proc.WaitForInputIdle();
SetParent(proc.MainWindowHandle, panel1.Handle);
btnGetsystemInfo.Text = "Get System Info";
btnGetsystemInfo.Enabled = true;
}
}
}
Thanks for watching!