Get the COM PORT

Jan 19, 2010 at 9:35 AM

I am using DotRas to write an application that allows me to create dial-up connections, but I also need to know which COM port the dialup connection is using. Is there anyway to retrieve this COM port?

Jan 19, 2010 at 1:54 PM

Unfortunately not right now. The devices retrieved by RasEnumDevices only tells me the name of the device and what type of device it is, I haven't found a way to tie it back to the hardware (yet). It's on my list of things to do, but as of right now DotRas is unable to determine any device specific settings.

I've created a work item you can follow if you want to know when it gets completed, but the last time I tried it I couldn't figure out how to tie the devices back to the actual hardware.

If you find out how to do it I'd be very interested to know.

Jan 19, 2010 at 4:02 PM

Try this to map Device Names and COM ports:


    Private ManObjReturn As ManagementObjectCollection


    Private ManObjSearch As ManagementObjectSearcher


    Private ManObj As ManagementObject


    Private Sub thing()

        ManObjSearch = New ManagementObjectSearcher("Select * from Win32_POTSModem")

        ManObjReturn = ManObjSearch.Get


        For Each ManObj In ManObjReturn

            ListBox1.Items.Add(CStr(ManObj("Name")) & _

            " Uses: " & CStr(ManObj("AttachedTo")))



    End Sub


I tested it and it works.

Jan 19, 2010 at 5:47 PM

Glad you found something that would work.

I won't be using WMI from the project, there's just way too many different devices and interfaces I'd have to store the queries for inside the code to manipulate the objects from it into something useful in the project. It might take some time, but eventually I'll probably have the functionality added to the project.

Good luck with your project!