C# system information
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: C# system information

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Posts
    1

    Question C# system information

    Hi, I'm trying to make a program in visual c# that displays computer information like graphics card model, graphics ram, system ram, cpu model, etc.

    Basically I have this, but it doesn't seem to work. Any help would be appreciated. If any other easier methods available please leave a comment telling me of such thanks:
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Management;
    using System.Management.Instrumentation;
    
    namespace WindowsFormsApplication1
    {
      public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
        }
    
      private void Form1_Load(object sender, EventArgs e)
      {
        ManagementObjectSearcher searcher = 
        new ManagementObjectSearcher("Select Name from Win32_CDROMDrive");
        ManagementObjectSearcher searcher2 =
        new ManagementObjectSearcher("Select Model from Win32_BaseBoard");
        foreach(ManagementObject cdrom in searcher.Get())
        foreach (ManagementObject model in searcher2.Get())
        {
          textBox1.Text = ("Name: " + cdrom.GetPropertyValue("Name").ToString());
          textBox2.Text = ("Name: " + model.GetPropertyValue("Model").ToString());
        }
      }
     }
    }
    I am very new to C# programming but have basic knowledge of visual basic if I can do this using that.
    Last edited by cilu; November 20th, 2009 at 02:05 AM.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: C# system information

    Describe what's not working? Are you seeing only the last property value? That is because you're overwriting the text in the two textboxes.
    Code:
          textBox1.Text = ("Name: " + cdrom.GetPropertyValue("Name").ToString());
          textBox2.Text = ("Name: " + model.GetPropertyValue("Model").ToString());
    Maybe you mean:
    Code:
          textBox1.Text += ("Name: " + cdrom.GetPropertyValue("Name").ToString());
          textBox2.Text += ("Name: " + model.GetPropertyValue("Model").ToString());
    And please use code tags.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center