Okey, my code for checking HWID is working fine, but when it comes the part to pass the the HWID in to string its not working, its returning blank.
This is the code i use
private void Form1_Load(object sender, EventArgs e)
{
string HWID = string.Empty;//creating a empty string
ManagementClass Management = new ManagementClass("win32_processor");//declaring the system management calss
ManagementObjectCollection MObject = Management.GetInstances();//decalring the system management object collection
foreach (ManagementObject mob in MObject)//having a foreach loop
{
if (string.IsNullOrEmpty(HWID))
{
HWID = mob.GetPropertyValue("processorID").ToString();//converting the HWID to string
break;
}
}
}
private void alphaBlendTextBox2_TextChanged(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
string loginUrl = "http://xxxxxx.xyz/customapi.php?username=" + alphaBlendTextBox1.Text + "&password=" + alphaBlendTextBox2.Text + "&hid=" + hwid + "&apiKey=APIKEYHERE&hid=" + HWID + "&ver=2";
to make everything even more clear im trying to make API call, everything is fine but when it comes to the HWID its failing.
//edit
I keep failing, if anyone williing to rewrite and fix the code ill be happy.. Thanks!
You have to declare the string "HWID" outside of Form1_Load.
So it looks like
string HWID = string.Empty;//creating a empty string
private void Form1_Load(object sender, EventArgs e)
{
ManagementClass Management = new ManagementClass("win32_processor");//declaring the system management calss
ManagementObjectCollection MObject = Management.GetInstances();//decalring the system management object collection
foreach (ManagementObject mob in MObject)//having a foreach loop
{
if (string.IsNullOrEmpty(HWID))
{
HWID = mob.GetPropertyValue("processorID").ToString();//converting the HWID to string
break;
}
}
}
I always did it like this
string HWID = String.Empty;
ManagementObjectSearcher moSearcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
foreach (ManagementObject mngObj in moSearcher.Get())
{
HWID = mngObj["ProcessorId"].ToString();
}