Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Get system information

Get system information

Scheduled Pinned Locked Moved C#
comtutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sammyh
    wrote on last edited by
    #1

    Anyone know how to get system info at runtime. I specifically need to find out what COM ports are installed. Thanks -Sam

    K 1 Reply Last reply
    0
    • S sammyh

      Anyone know how to get system info at runtime. I specifically need to find out what COM ports are installed. Thanks -Sam

      K Offline
      K Offline
      Kannan Kalyanaraman
      wrote on last edited by
      #2

      Hi Sam, Take a look at System.Management namespace, its a wrapper for WMI, you might find what you are looking for. Cheers Kannan

      T 1 Reply Last reply
      0
      • K Kannan Kalyanaraman

        Hi Sam, Take a look at System.Management namespace, its a wrapper for WMI, you might find what you are looking for. Cheers Kannan

        T Offline
        T Offline
        thematt
        wrote on last edited by
        #3

        Try this out: private void btnComPorts_Click(object sender, System.EventArgs e) { txtOutput.Clear(); string server = @"\\" + txtServer.Text; ManagementScope ms = new ManagementScope(server + @"\root\cimv2"); ObjectQuery oq = new ObjectQuery("select deviceID from win32_SerialPort"); ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq); ManagementObjectCollection moc = mos.Get(); foreach(ManagementObject mo in moc) { txtOutput.AppendText(mo["DeviceID"].ToString()); txtOutput.AppendText("\r\n"); } } Matt is a network administrator for an auditing company in the midwest. He is shamelessly looking for Windows programming side work.

        S 1 Reply Last reply
        0
        • T thematt

          Try this out: private void btnComPorts_Click(object sender, System.EventArgs e) { txtOutput.Clear(); string server = @"\\" + txtServer.Text; ManagementScope ms = new ManagementScope(server + @"\root\cimv2"); ObjectQuery oq = new ObjectQuery("select deviceID from win32_SerialPort"); ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq); ManagementObjectCollection moc = mos.Get(); foreach(ManagementObject mo in moc) { txtOutput.AppendText(mo["DeviceID"].ToString()); txtOutput.AppendText("\r\n"); } } Matt is a network administrator for an auditing company in the midwest. He is shamelessly looking for Windows programming side work.

          S Offline
          S Offline
          sammyh
          wrote on last edited by
          #4

          Thanks Matt, worked excellent!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups