Broadcast message to multiple users
Is it possible to use the following code to broadcast a message to the entire network instead of just one user?
VB Code:
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 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
'Broadcast message via API
If NetMessageBufferSend(ByVal 0&, ToName(0), FromName2(0), _
MessageToSend(0), UBound(MessageToSend)) = NERR_Success Then
BroadcastMessage = True
End If
End Function
Private Sub Command1_Click()
BroadcastMessage "DOMAIN", "ADMIN", "We are going to be doing some server maintainence, please save your work and log off as soon as possible. The Admin"
End Sub
I've tried putting the Domain name in instead of user name, and it doesn't work, I've tried * cause that works with Net Send, but it doesn't work with the API. Does anyone know if it's possible? I thought about listing all logged in users, and looping through and sending to each one, but that would be a terrible strain on the server...
Thanks
-Joey
[/Highlight]