当我尝试通过友好名称在Win 7 x32上显示我的串行端口时,无论是物理还是虚拟,它都能正常工作,但是当我在Win 8.1 x64上尝试它时,只显示虚拟端口。当我删除虚拟它没有显示任何错误实际上它只是加载表单。
Try
'Dim searcher As New ManagementObjectSearcher("root\cimv2", "SELECT * FROM Win32_SerialPort where Description='Prolific USB-to-Serial Comm Port'")
Dim searcher As New ManagementObjectSearcher("root\cimv2", "SELECT * FROM Win32_SerialPort ")
For Each queryObj As ManagementObject In searcher.Get()
RichTextBox1.Text &= queryObj("Name") & Chr(32) & queryObj("DeviceID") & vbCr
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
几乎忘了我试图检测USB到RS-232但没有运气。