26-03-23, 02:48 PM
تحويل الكود إلى C#:
هذا هو الكود النهائي
كود :
using System.Management;
using Microsoft.Win32;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}هذا هو الكود النهائي
كود :
private void Form1_Load(object sender, EventArgs e)
{
TxtWnd.Text = My.Computer.Info.OSFullName;
TxtMname.Text = System.Environment.MachineName;
TxtLang.Text = My.Computer.Info.InstalledUICulture.EnglishName;
var cmicWmi = new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
string diskId; // Digital ID
string diskSerialNumber; // This we will call it the serial number for the time being.
string diskModel; // Serial number
foreach (ManagementObject cmicWmiObj in cmicWmi.Get())
{
diskId = cmicWmiObj["signature"].ToString();
diskSerialNumber = cmicWmiObj["serialnumber"].ToString();
diskModel = cmicWmiObj["Model"].ToString();
}
TextBox1.Text = diskSerialNumber;
TextBox2.Text = diskId;
TextBox4.Text = (Convert.ToInt32(TextBox2.Text) * 13 + 1225 - 1650).ToString();
TextBox4.Text = (Convert.ToInt32(TextBox4.Text) * 17).ToString();
}
private void Button1_Click(object sender, EventArgs e)
{
if (TextBox3.Text == TextBox4.Text)
{
MessageBox.Show("تمت عملية تفعيل البرنامج بنجاح");
var x = TextBox3.Text;
RegistryKey Activekey;
Activekey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
Activekey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\FoxSoftware", true);
if (Activekey == null)
{
Activekey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
Activekey.CreateSubKey("FoxSoftware");
Activekey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\FoxSoftware", true);
Activekey.SetValue("System_key", x);
Activekey.Close();
}
}
else
{
MessageBox.Show("رقم التفعيل الذي ادخلته غير صحيح الرجاء مراجعة قسم المبيعات");
Application.Exit();
}
}