网站建设资讯

NEWS

网站建设资讯

vb.net计算机信息 计算机VB

vb.net程序如何实现向电脑的Com口发送一段字符串信息,之后再接收显示发送的字符串信息?

'vb.net的串口接收数据要用到委托

创新互联是一家集网站建设,赛罕企业网站建设,赛罕品牌网站建设,网站定制,赛罕网站建设报价,网络营销,网络优化,赛罕网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

Delegate Sub SetTextCallback(ByVal InputString As String) '声明一个委派类,并声明符合函数参数有一个,而其型态是字符串

Private Sub ShowString(ByVal comData As String)

txt_Re.Text = comData '将收到的数据入接收文字框中--- txt_Re.Text 是接收用的文本框

txt_Re.SelectionStart = txt_Re.Text.Length

txt_Re.ScrollToCaret()

End Sub

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived‘自动接收事件

Dim inData As String = SerialPort1.ReadExisting

Dim d As New SetTextCallback(AddressOf ShowString)

Invoke(d, inData)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '发送指令

SerialPort1.Write("123")

End Sub

vb.net 获取局域网计算机的当前用户名和计算机型号等信息

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub GetName()

Dim sJM As String

Dim sMC As String

Dim sIP As String

Dim s As String

s = String(128, Chr(0))

GetComputerName s, Len(s)

s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))

sJM = s'计算机名称

s = String(128, Chr(0))

GetUserName s, Len(s)

s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))

sMC = s‘当前用户名称

End Sub

'用这种方法在远程获得再发回本机就可以吧

'取计算机型号暂时不会

VB.Net如何查看计算机硬件的详细属性(如:查看U盘的位置)?

先引用system.io

之后声明类型为 DriveInfo 的变量

声明的对象中包含 一些方法


网站题目:vb.net计算机信息 计算机VB
转载来源:http://cdweb.net/article/hjcocd.html