 |
| Using the NetMessageBufferSend to send messages on the network |
User rating: 0/10 (0 votes) | |
|
|
 |
 |
Versions: click to open |
 |
|
 |
 |
| Before you begin: |
 |
This example shows how to broadcast system alerts using the NetMessageBufferSend as an alternative to NET SEND command.
On Windows XP computer, make sure that the Messenger service is running:

If the Messenger service is not running, upon creating an instance of the NetMessages object you will get error code 2184 (The service has not been started).
If a service is stopped and not disabled, you can start it programmatically using VFP Windows Services class library :
#DEFINE SERVICE_WIN32 0x30
#DEFINE SERVICE_RUNNING 4
LOCAL ws As winservices, srv As winservice
ws = CREATEOBJECT("winservices",;
Null, Null, SERVICE_WIN32)
srv = ws.GetService("Messenger")
IF srv.currentstate <> SERVICE_RUNNING
= MESSAGEBOX("The Messenger service is off!")
* srv.StartService
ENDIF
See also:
Using mailslots to send messages on the network
Peer-to-peer LAN messenger built with Mailslot API functions
How to create non-blocking Winsock server
A client for testing non-blocking Winsock server
Using WM_COPYDATA for interprocess communication
|
 |
 |
| |
| |
Members area. Log in to view this example. |
|
| |
|
|
|
|
|
 |
User rating: 0/10 (0 votes) | |
| 4070 bytes Created: 2005-09-14 13:41:48 Modified: 2011-12-10 09:20:22 Visits in 7 days: 161 |
|
 |
 |
| Listed functions: |
 |
|
 |
 |
| My comment: |
 |
Note that this code sample does not work on Win9* computers.
Sending a message:
obj = CREATEOBJECT("NetMessages")
IF obj.errorno = 0
obj.SendMessage("WKSTATION1", "Test message")
ENDIF
Sending a message from a server (must have admin rights):
obj = CREATEOBJECT("NetMessages", "MYSERVER")
IF obj.errorno = 0
obj.SendMessage("WKSTATION1", "Test message")
ENDIF
Sending a message to all domain computers (note an asterick after the domain name):
obj = CREATEOBJECT("NetMessages")
IF obj.errorno = 0
obj.SendMessage("MYDOMAIN*", "Test message")
ENDIF
Sometimes it takes time for the NetMessageBufferSend to return control. The mailslot approach turns around much faster.
Use [domain name]* to broadcast a message to all domain computers.
On the target computer, TCP port 139 (NetBIOS) is assigned to receive messages.
* * *
C# version contains classes NetMessage and NetMessageThread.
The first class sends messages while staying in the main thread of the calling process. Exactly as FoxPro does. It causes the process wait until the NetMessageBufferSend returns. Sometimes this delay becomes noticeable -- up to 1 minute -- especially when the message receipient is disconnected or the network name is invalid or does not exist.
The NetMessageThread class sends messages using a separate thread it creates for each message. The calling process immediately gets the control back, because the delay belongs to another thread.
|
 |
 |
| Word Index links for this example: |
 |
|
|
 |
 |
| Translate this page: |
 |
|