Using Win32 functions in Visual FoxPro Image Gallery
Network Management
..msdn
NetApiBufferFree
NetApiBufferSize
NetConnectionEnum
NetFileClose
NetFileEnum
NetFileGetInfo
NetGetDCName
NetGroupEnum
NetLocalGroupEnum
NetMessageBufferSend
NetMessageNameAdd
NetMessageNameDel
NetMessageNameEnum
NetScheduleJobAdd
NetScheduleJobDel
NetScheduleJobEnum
NetServerEnum
NetServerGetInfo
NetSessionEnum
NetShareAdd
NetShareDel
NetShareEnum
NetShareSetInfo
NetUserAdd
NetUserChangePassword
NetUserDel
NetUserEnum
NetUserGetGroups
NetUserGetInfo
NetUserGetLocalGroups
NetUserSetInfo
NetWkstaGetInfo
NetWkstaTransportEnum
NetWkstaUserEnum
Code examples:
Using the NetMessageBufferSend to send messages on the network
Using the NetMessageBufferSend to send messages on the network

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
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 name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    4070 bytes  
    Created: 2005-09-14 13:41:48  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 124  
    Listed functions:
    GetLastError
    NetApiBufferFree
    NetApiBufferSize
    NetMessageBufferSend
    NetMessageNameAdd
    NetMessageNameDel
    NetMessageNameEnum
    Printer friendly API declarations
    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:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Google
    Advertise here!