none
serialport 问题 RRS feed

  • 问题


  • Dim keyCom As RegistryKey = Registry.LocalMachine.OpenSubKey("Hardware\DeviceMap\SerialComm")
            If keyCom IsNot Nothing Then
                Dim sSubKeys As String() = keyCom.GetValueNames()
                For Each sName As String In sSubKeys
                    Dim sValue As String = DirectCast(keyCom.GetValue(sName), String)
                    If sValue <> "" Then
                        If send_monitor(sValue) Then
                            sql = "update crm_Com set [status] = '已连接' where DKH='" & sValue.Replace("COM", "") & "'"
                        Else
                            sql = "update crm_Com set [status] = '未连接' where DKH='" & sValue.Replace("COM", "") & "'"
                        End If
                    End If
                Next
            End If
    Function send_monitor(ByVal m_port As String) As Boolean
            Try
                Connect_com(m_port)
                Dim sb As New StringBuilder()
                Thread.Sleep(500)
                Dim sBack As String = WriteAtCommand("AT")
                Thread.Sleep(500)
                If sBack <> "" Then
                    If sBack.IndexOf("OK") <> -1 Then
                        Return True
                    End If
                End If
                Disconnect_com()
            Catch ex As Exception
                Disconnect_com()
                Return False

            End Try
        End Function

    总是报   已关闭 Safe handle  错误如何修改

    2009年9月23日 3:12

答案

全部回复