1

I have a com port and i want to send messages to it. I want to be certain that is port is of the type RS 485. How can i do that. I have searched online and the only way i see is through the win32 dll. is there any other way and if there isnt could you please point me to the win32 method. I have the following code but it doesnt produce any output...

    Dim searcher As New ManagementObjectSearcher("root\cimv2", "SELECT * FROM Win32_SerialPort")

    For Each queryObj As ManagementObject In searcher.Get()
        Dim obj As String = queryObj("Name")
        MessageBox.Show(obj)

    Next
TheNoob
  • 185
  • 1
  • 12
  • [Windows Management Instrumentation](https://msdn.microsoft.com/en-us/library/aa394582(v=vs.85).aspx). Implemented by @Plutonix in [Monitor USB drives and retrieve device Info using a DeviceWatcher](https://stackoverflow.com/questions/24944865/monitor-usb-drives-and-retrieve-device-info-using-a-devicewatcher). – Jimi Dec 28 '17 at 17:12
  • @Jimi do you see anything wrong in the code? – TheNoob Dec 28 '17 at 18:21
  • Nothing (if you don't care what Option.Strict might say about queryObj("Name")). If you check the `ProviderType` Property in `queryObj.Properties`, it gives you the full name of the serial port. – Jimi Dec 28 '17 at 19:19
  • Well, what I wrote wasn't that clear. _it gives you the full name of the serial port_ **type**. You can get it with `queryObj.Properties("ProviderType").Value.ToString`. For a standard serial port will be "RS232 Serial Port" – Jimi Dec 28 '17 at 20:10
  • I could figure out how to get it. Thanks! – TheNoob Dec 28 '17 at 20:11

0 Answers0