利用了一个API 申明如下 Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (Server As Any, yToName As Byte, yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long自写一个消息发送的函数 Private Function SendMsg(sToUser As String, sFromUser As String, sMessage As String) As Boolean
Dim yToName() As Byte Dim yFromName() As Byte Dim yMsg() As Byte Dim l As Long
yToName = sToUser & vbNullChar yFromName = sFromUser & vbNullChar yMsg = sMessage & vbNullChar If NetMessageBufferSend(ByVal 0&, yToName(0), yFromName(0), yMsg(0), UBound(yMsg)) = NERR_Success Then SendMsg = True End If End Function具体实现部分 X = SendMsg(adress, SentFrom, TxtMsg.Text)'adress为机器名或IP,SentFrom为发送方,Txtmsg.text为消息内容 If X Then StatusBar1.Panels(6) = "消息发送成功" Else StatusBar1.Panels(6) = "消息发送失败" End If
申明如下
Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (Server As Any, yToName As Byte, yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long自写一个消息发送的函数
Private Function SendMsg(sToUser As String, sFromUser As String, sMessage As String) As Boolean
Dim yToName() As Byte
Dim yFromName() As Byte
Dim yMsg() As Byte
Dim l As Long
yToName = sToUser & vbNullChar
yFromName = sFromUser & vbNullChar
yMsg = sMessage & vbNullChar If NetMessageBufferSend(ByVal 0&, yToName(0), yFromName(0), yMsg(0), UBound(yMsg)) = NERR_Success Then
SendMsg = True
End If
End Function具体实现部分 X = SendMsg(adress, SentFrom, TxtMsg.Text)'adress为机器名或IP,SentFrom为发送方,Txtmsg.text为消息内容
If X Then
StatusBar1.Panels(6) = "消息发送成功"
Else
StatusBar1.Panels(6) = "消息发送失败"
End If