I need help in C# with getting individual memory values from Win32_PhysicalMemory into separate text boxes with singe line
public void MEMInfo()
{
ManagementObjectSearcher mos = new ManagementObjectSearcher("root\\CIMV2",
"Win32_PhysicalMemory");
foreach(ManagementObject wmi in mos.Get())
{
try
{
this.Mem1Tag.text = wmi.GetPropertyValue("Tag").ToString();
this.Mem2Tag.text = wmi.GetPropertyValue("Tag").ToString();
this.Mem3Tag.text = wmi.GetPropertyValue("Tag").ToString();
this.Mem4Tag.text = wmi.GetPropertyValue("Tag").ToString();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
All I get is:
textbox1: Physical Memory 3
textbox2: Physical Memory 3
textbox3: Physical Memory 3
textbox4: Physical Memory 3
I know how to do this with one textbox with mutiline but I want to place the Memory values into separate text boxes so that it appearers like.
textbox1: Physical Memory 0
textbox2: Physical Memory 1
textbox3: Physical Memory 2
textbox4: Physical Memory 3
#region CPUInfo()
public void CPUInfo()
{
mos = new ManagementObjectSearcher(scope, query + obj[2]);
foreach(ManagementObject wmi in mos.Get())
{
try
{
this.CPUman.Text = wmi.GetPropertyValue(value[0]).ToString();
this.CPUmod.Text = wmi.GetPropertyValue(value[1]).ToString();
this.CPUcore.Text = wmi.GetPropertyValue(value[2]).ToString();
this.CPUthreads.Text = wmi.GetPropertyValue(value[3]).ToString();
this.cacheL2.Text = CPUcore.Text.ToString() + " x " + wmi.GetPropertyValue(value[4]).ToString() + " KB";
this.cacheL3.Text = CPUcore.Text.ToString() + " x " + wmi.GetPropertyValue(value[5]).ToString() + " KB";
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
if(CPUthreads.Text != CPUcore.Text)
{
ThredingB.Checked = true;
}
else
{
ThredingB.Checked = false;
}
}
#endregion
This is the CPU code that dose work because I wrote it :-). I don't need or want help from who this I am "confused". I'v just hit a brick wall that Google can't seam to help me with.
scope = "root\\CIMV2"
query = "SELECT * FROM "
obj[6] = "Win32_PhysicalMemory"