-
Feb 8th, 2018, 11:30 PM
#1
Thread Starter
Fanatic Member
Comm Port
Hi
How to get the Number of USB to Serial Port Comm Port . Number gets frequently changed.
Thanks
-
Feb 9th, 2018, 06:52 PM
#2
Re: Comm Port
You can check Device Manager. Note that the COM port numbers can go way up to at least 98 or 99. You may want to look into limiting this by a registry setting so that they don't exceed 10 or so, since some software can't handle higher COM port numbers.
https://stackoverflow.com/questions/...om-port-number
http://woshub.com/how-to-clean-up-an...-in-windows-7/
-
Feb 10th, 2018, 09:54 AM
#3
Addicted Member
Re: Comm Port
Originally Posted by Jagjit
Hi
How to get the Number of USB to Serial Port Comm Port . Number gets frequently changed.
Thanks
Why is it changing? Is the Serial com cable being plugged into different USB ports at various times. For example, like where a service tech has to connect to different computers and needs to get his diagonistic reader to receive the signal, which on different computers would be coming over differing ports depending on what port assignments had already been made by the computer for other components?
-
Feb 12th, 2018, 09:05 AM
#4
Re: Comm Port
This is for .Net so you'll need to convert back to VB6, but this is how I do it.
VB.Net Code:
Public Function findComDevice(ByVal PartialName As String) As String Try Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim mo As Management.ManagementObject moSearch = New Management.ManagementObjectSearcher("Select * from Win32_PnPEntity") moReturn = moSearch.Get For Each mo In moReturn If IsNothing(mo.Properties.Item("Name").Value) Then Continue For If CStr(mo.Properties.Item("Name").Value).ToUpper.Contains(PartialName.ToUpper) Then 'returns something like: "Prolific USB-to-Serial Comm Port (COM17)" Dim IPRegEx As Regex = New Regex("(?<=\().*?(?=\))") Return IPRegEx.Match(mo.Properties.Item("Name").Value.ToString).Value End If Next Return Nothing Catch ex As Exception Messagebox.Show(ex.ToString) Return Nothing End Try End Function
-
Feb 12th, 2018, 02:16 PM
#5
Re: Comm Port
I don't know if this helps you, but I just posted this:
EnumPorts - Find the system's COM and/or LPT ports
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|