1、加API: Public Declare Function NetMessageBufferSend Lib _ "NETAPI32.DLL" _ (Server As Any, _ yToName As Byte, _ yFromName As Any, _ yMsg As Byte, _ ByVal lSize As Long) As Long'创建信使服务Public Function SendMsg(sToUser As String, sFromUser As String, sMessage As String) As Boolean 2、调用以下方法'------------------------------------------- ' ' 函数名 发消息(信使) ' '传入参数 'sToUser: 被发送对象机器名或IP 'sFromUser: 发送者机器名或IP 'sMessage: 消息内容 ' '返回值 'SendMsg: 布尔值 T:成功、F:失败'2004/02/05 '-------------------------------------------- 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), _ ByVal 0&, yMsg(0), _ UBound(yMsg)) = NERR_Success Then SendMsg = True End If End Function 3、加分!!!!!!!!
试试Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" _ (Server As Any, _ yToName As Byte, _ yFromName As Any, _ yMsg As Byte, _ ByVal lSize As Long) _ As LongPrivate Sub Command1_Click() Dim X As Boolean X = SendMsg(TxtTo.Text, TxtFrom.Text, TxtMsg.Text) If X Then MsgBox "消息已被成功发送", vbInformation, "发送消息" Else MsgBox "发送消息失败", vbCritical, "发送消息" End If End SubPrivate 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), _ ByVal 0&, yMsg(0), UBound(yMsg)) = NERR_Success Then SendMsg = True End If End FunctionPrivate Sub Command2_Click() End End Sub
Public Declare Function NetMessageBufferSend Lib _
"NETAPI32.DLL" _
(Server As Any, _
yToName As Byte, _
yFromName As Any, _
yMsg As Byte, _
ByVal lSize As Long) As Long'创建信使服务Public Function SendMsg(sToUser As String, sFromUser As String, sMessage As String) As Boolean
2、调用以下方法'-------------------------------------------
'
' 函数名 发消息(信使)
'
'传入参数
'sToUser: 被发送对象机器名或IP
'sFromUser: 发送者机器名或IP
'sMessage: 消息内容
'
'返回值
'SendMsg: 布尔值 T:成功、F:失败'2004/02/05
'--------------------------------------------
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), _
ByVal 0&, yMsg(0), _
UBound(yMsg)) = NERR_Success Then
SendMsg = True
End If
End Function
3、加分!!!!!!!!
(Server As Any, _
yToName As Byte, _
yFromName As Any, _
yMsg As Byte, _
ByVal lSize As Long) _
As LongPrivate Sub Command1_Click()
Dim X As Boolean
X = SendMsg(TxtTo.Text, TxtFrom.Text, TxtMsg.Text)
If X Then
MsgBox "消息已被成功发送", vbInformation, "发送消息"
Else
MsgBox "发送消息失败", vbCritical, "发送消息"
End If
End SubPrivate 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), _
ByVal 0&, yMsg(0), UBound(yMsg)) = NERR_Success Then
SendMsg = True
End If
End FunctionPrivate Sub Command2_Click()
End
End Sub