๐ฉโ๐ป ๅๅพ Windows Product Id
ไฝฟ็จๆฅ่ฉข
Win32_OperatingSystem
้กๅฅ๏ผ็ถๅพ็ฒๅๆไฝ็ณป็ตฑ็็ขๅ่ญๅฅ็ขผ๏ผ
SerialNumber
ๅฑฌๆง๏ผ
caution
ๆ นๆๆไฝ็ณป็ตฑ็ๆฌๅๆฌ้๏ผๆๆๅฏ่ฝ็กๆณ็ฒๅๆไฝ็ณป็ตฑ็็ขๅ่ญๅฅ็ขผ
้ๅ่จๆฏๆๆๆๅๅฐไฟ่ญท๏ผๅชๆ็ณป็ตฑ็ฎก็ๅกๆฌ้ๆ่ฝ่จชๅ
using System;
using System.Management;
class Program
{
static void Main()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject m in collection)
{
// ็ฒๅ็ขๅ่ญๅฅ็ขผ
string productId = m["SerialNumber"].ToString();
Console.WriteLine("ๆไฝ็ณป็ตฑ็ขๅ่ญๅฅ็ขผ: " + productId);
}
}
catch (Exception e)
{
Console.WriteLine("็กๆณ็ฒๅๆไฝ็ณป็ตฑ็ขๅ่ญๅฅ็ขผ: " + e.Message);
}
}
}