端口扫描器java项目开发_vb写端口扫描器

hacker|
102

vb.net 读取扫描枪USB接口数据的实例

USB比较难抓数据,建议是USB模拟串口,或者直接就是串口,这样数据比较好抓。

USB上传模式是鼠标光标在哪数据就上传在哪,所以你抓USB的数据的很难!

X猫-思刊办公专营店

我有一个扫描枪,通过USB与电脑连接且显示为COM2。我想通过VB窗体的按钮来控制扫描枪的触发请问怎样实现?

1,为什么不通过扫描枪扫描条码来触发你程序里面的事件?

2,通过软件来控制扫描枪的触发有什么意义?

3,扫描枪就是一个模拟键盘输入设备,你可以把扫描枪想象为一个键盘,此时你要求实现的功能可以理解为控制一个键盘是否允许输入而已。如果你一定要这么干,那么程序里面直接控制com口的通断即可。没必要搞的那么复杂。

请问vb程序如何获取扫描数据?

扫描器会有驱动程序把扫描后得到的数据输出,你只要接收现成的数据就可以了

用VB写端口映射代码 越简单越好

Option Explicit

Dim bMsg() As Byte

Private Sub Form_Load()

Dim strCTemp As String

Dim intCPTemp As Variant

'侦听端口

Winsock1.LocalPort = 2000

Winsock1.Listen

'向Sphere转发数据

Winsock2.RemoteHost = "127.0.0.1"

Winsock2.RemotePort = 2001

Winsock2.Connect

Do While Winsock2.State 7

If Winsock2.State = 9 Or Winsock2.State = 0 Then Winsock2.Close: Exit Do

Select Case Winsock2.State

Case 1

strCTemp = "已打开!"

Case 2

strCTemp = "正在侦听.."

Case 3

strCTemp = "与服务器连接挂起!"

Case 4

strCTemp = "正在识别主机.."

Case 5

strCTemp = "已识别主机!"

Case 6

strCTemp = "正在与服务器连接.."

Case 8

strCTemp = "同级人员正在关闭连接.."

Case 9

strCTemp = "出错"

Winsock2.Close

End Select

If Winsock2.State intCPTemp Then

intCPTemp = Winsock2.State vbCrLf

Text1.Text = Text1.Text strCTemp vbCrLf

End If

DoEvents

Loop

If Winsock2.State = 7 Then

Text1.Text = Text1.Text strCTemp "已成功连接上服务器..." vbCrLf

End If

End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)

If Winsock1.State sckClosed Then Winsock1.Close

Winsock1.Accept requestID

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

ReDim bMsg(bytesTotal)

Winsock1.GetData bMsg

Text1.Text = Text1.Text bytesTotal vbCrLf

Text1.SelStart = Len(Text1.Text)

Winsock2.SendData bMsg

End Sub

Private Sub Winsock2_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

Text1.Text = Text1.Text "Winsock2出错!" vbCrLf

End Sub

Private Sub Winsock2_SendComplete()

Text1.Text = Text1.Text "向Sphere发送了数据.." vbCrLf

End Sub

Private Sub Winsock2_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)

Text1.Text = Text1.Text "向Sphere发送了" bytesSent "数据.." vbCrLf

End Sub

0条大神的评论

发表评论