Foxtable(狐表)用户栏目专家坐堂 → 怎樣轉換這段VB.net代碼為FT代碼


  共有4257人关注过本帖树形打印复制链接

主题:怎樣轉換這段VB.net代碼為FT代碼

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/5/15 16:06:00 [显示全部帖子]

 如下。全局代码那里输入

 

Public Class SearchforUSBCom
    'Search for the virtual serial port created by usbclient.
    Public Function SearchforCom(ByRef sCom As String) As Boolean
        Dim sComValue As String
        Dim sTmpara As String
        Dim myReg As Microsoft.Win32.RegistryKey
        myReg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("HARDWARE\\DEVICEMAP\\SERIALCOMM")

        Dim sComName() As String
        sComName = myReg.GetValueNames() 'strings array composed of the key name holded by the subkey "SERIALCOMM"
        Dim i As Integer
        For i = 0 To sComName.Length - 1
            sComValue = myReg.GetValue(sComName(i)).ToString() 'obtain the key value of the corresponding key name
            If sComValue = "" Then
                Continue For
            End If

            sCom = ""
            Dim j As Integer
            If sComName(i) = "\Device\USBSER000" Then 'find the virtual serial port created by usbclient
                For j = 0 To 10
                    sTmpara = ""
                    Dim myReg2 As Microsoft.Win32.RegistryKey
                    myReg2 = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_1B55&PID_B400\\" & j.ToString() & "\\Device Parameters")

                    If myReg2 IsNot Nothing Then
                        sTmpara = myReg2.GetValue("PortName").ToString()

                        If sComValue = sTmpara Then
                            sCom = sTmpara
                            Return True
                        End If
                    End If
                Next
            End If
        Next
        Return False
    End Function
End Class


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/5/15 16:07:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/5/15 16:14:00 [显示全部帖子]

是的,亲

 回到顶部