How do you populate a listbox with all available LPT,Com and USB ports?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How do you populate a listbox with all available LPT,Com and USB ports?

  1. #1
    Join Date
    Feb 2011
    Posts
    13

    How do you populate a listbox with all available LPT,Com and USB ports?

    Hi gang,

    How do you populate a listbox with all available LPT,Com and USB ports?

    I'd like to use a Form, and on form load, collect all LPT, Serial and USB ports on the current system and have them populate a listBox on the form.

    Has anyone got a snippet?


    SteveyD

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,289

    Re: How do you populate a listbox with all available LPT,Com and USB ports?

    Read up on WMI in msdn.

  3. #3
    Join Date
    Sep 2013
    Location
    Wisconsin
    Posts
    5

    Re: How do you populate a listbox with all available LPT,Com and USB ports?

    I don't do much work with LPT or USB, but for Com I use:

    Code:
                string[] PortList = SerialPort.GetPortNames();
                foreach (string p in PortList)
                {
                    this.PortCB.Items.Add(p);
                }

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