ChBollaert
Apr 3rd, 2001, 12:29 AM
Morning everybody,
Can someone give me a bit of help, I try to send a message over a local network using API, but if I do it the way the original author suggested it wont work, if I use two times the messagevariabel the message comes true, but the usernamefrom is replaced with the machinenumber.
If I do it using the parameters "UserTo,UserFrom,Message", the message won't be sent, instate the username USERFRom will be displayed as a message.
I can't find out what's wrong.
Private Declare Function NetMessageBufferSend Lib "Netapi32.dll" _
(yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, _
ByVal lSize As Long) As Long
Private Const Nerr_Success As Long = 0&
-------------------------------------------------------
Public Sub Sturen()
Dim antw As Boolean
Dim message As String
Dim UserToSend As String
Static i As Integer
message = "Hello World"
For i = LBound(UserId) To UBound(UserId)
UserToSend = UserId(i)
/////////////////////////////////////////////////////////////////////
antw = BroadCastMessage(UserToSend, message, message)
/////////////////////////////////////////////////////////////////////
Next
For i = LBound(UserId) To UBound(UserId)
UserId(i) = ""
Next
End Sub
-------------------------------------------------------------------
Public Function BroadCastMessage(UserOrMachine As String, _
FromName As String, message As String) As Boolean
Dim ToName() As Byte
Dim FromName2() As Byte
Dim MessageToSend() As Byte
ToName = UserOrMachine & vbNullChar
FromName2 = FromName & vbNullChar
MessageToSend = message & vbNullChar
If NetMessageBufferSend(ByVal 0&, ToName(0), ByVal 0&, _
FromName2(0), UBound(MessageToSend)) = Nerr_Success Then
BroadCastMessage = True
End If
End Function
--------------------------------------------------------------
Can someone give me a bit of help, I try to send a message over a local network using API, but if I do it the way the original author suggested it wont work, if I use two times the messagevariabel the message comes true, but the usernamefrom is replaced with the machinenumber.
If I do it using the parameters "UserTo,UserFrom,Message", the message won't be sent, instate the username USERFRom will be displayed as a message.
I can't find out what's wrong.
Private Declare Function NetMessageBufferSend Lib "Netapi32.dll" _
(yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, _
ByVal lSize As Long) As Long
Private Const Nerr_Success As Long = 0&
-------------------------------------------------------
Public Sub Sturen()
Dim antw As Boolean
Dim message As String
Dim UserToSend As String
Static i As Integer
message = "Hello World"
For i = LBound(UserId) To UBound(UserId)
UserToSend = UserId(i)
/////////////////////////////////////////////////////////////////////
antw = BroadCastMessage(UserToSend, message, message)
/////////////////////////////////////////////////////////////////////
Next
For i = LBound(UserId) To UBound(UserId)
UserId(i) = ""
Next
End Sub
-------------------------------------------------------------------
Public Function BroadCastMessage(UserOrMachine As String, _
FromName As String, message As String) As Boolean
Dim ToName() As Byte
Dim FromName2() As Byte
Dim MessageToSend() As Byte
ToName = UserOrMachine & vbNullChar
FromName2 = FromName & vbNullChar
MessageToSend = message & vbNullChar
If NetMessageBufferSend(ByVal 0&, ToName(0), ByVal 0&, _
FromName2(0), UBound(MessageToSend)) = Nerr_Success Then
BroadCastMessage = True
End If
End Function
--------------------------------------------------------------