Sending "Pop Up" Messages via NetMessageXXX Functions

Environment and Other Notes

  • Compiler: VC++ 5
  • Libs: Standard plus netapi32.lib
  • Source: Included, compiles cleanly at warning 4, non MFC
  • Copyright: None
  • Unicode: Yes, required
This article demonstrate the proper usage of some of the NT NetMessageXXX functions by sending a pop-up message to any logged in user on the network or list the user names on your NT server.

When I started this little code sample, I needed a way to programmatically send a pop-up message to a specific user. I found the documentation to be sparse and the sample code to be non-existent.

In sending a pop-up message to a user using NetMessageBufferSend() I found that many of the documented parameters were hard to understand and once understood I could obtain that information programmatically too (i.e. server name). So, basically I implemented four basic calls to the NetXxx API:

  • NetMessageNameEnum() - Which gets the names of the alias (user names) on the specified server.
  • NetMessageBufferSend() - Which sends a message to a specified user.
  • NetServerGetInfo() - Which gets the name of the server we're running on.
  • NetWkstaUserGetInfo() - Which gets the name of the user account we're logged in as.
Viewing the code you can see how calls are made to each of the above functions and how NT will allocate a data buffer for you (the Get functions) and you must then release the data buffer yourself using GlobalFree().

I did not implement the remote server aspects of these calls. I played around with them a little but was not successful in determining the proper format for the server string. Since, for my own purposes I only needed local access I did not pursue this issue (but I would like to know how it works).

Also, the NetMessageBufferSend() does not return an accurate return code if you don't have proper security rights. Logged on to an NT Workstation under a user id that does not have Administrator rights and attempting to send a message to anyone, including your self and NetMessageBufferSend() returns immediately with an error code of NERR_NameNotFound. When logged in with Administrator rights this return code is not seen and the message is indeed sent (even to yourself). The documentation clearly states that you do not need special rights to use this API unless you are accessing a server remotely and this proved to not be the case.

As for the program, it accepts a user name to send a pop-up message to and a message to send. The message must be surrounded by quotes or else just the first word of the message will be sent.

Downloads

Download demo project - 30 Kb


Comments

  • on which computer is the user logged on

    Posted by Legacy on 12/24/2003 12:00am

    Originally posted by: Johan van Zijl

    The netsend system apparently knows on which computer the user, who recieves the message, is logged on. Is it possible to fetch this computer name?

    Reply
  • how to disable message service?

    Posted by Legacy on 01/05/2003 12:00am

    Originally posted by: yousen

    how to disable message service?

    Reply
  • Relationship with NetBIOS?

    Posted by Legacy on 12/10/2002 12:00am

    Originally posted by: liaojiping

    Is there any Relationship With NetBios for NetMessageBufferSend?

    Reply
  • NetSend Retry

    Posted by Legacy on 07/15/2002 12:00am

    Originally posted by: Anton

    When sending a message to a switched-off PC, NetMessageBufferSend (NetSend) is retrying for some time, before eventually giving up. Is there any way that this delay can be reduced?

    In my work situation I need to inform users of critical system failures immediately. It is taking just to long to reach all when some PC's are switched off (500 - 700)

    Thanks

    Reply
  • Here is a way to capture the popup message

    Posted by Legacy on 07/10/2002 12:00am

    Originally posted by: Srivisagan

    first capture the Messenger Service window and using EnumChildwindows api find the message
    extract the things u want it
    then
    close the window by using sendMessage function in the win32api

    i have completed the full code but i am interested in finding a way to capture it without popup.
    visagan

    Reply
  • help about inter net messaging system

    Posted by Legacy on 01/09/2002 12:00am

    Originally posted by: mihir

    How can i develop a project like Internet Messaging System
    in a data Network??(* can any body suggest me?)

    Reply
  • How to receive message, sent by NetMessageXXX() ???

    Posted by Legacy on 09/12/2001 12:00am

    Originally posted by: Phong Tran

    Hi all


    How to receive message, sent by NetMessageXXX() ???
    I want build a program which receice message, sent by NetMessageXXX()

    Thanks
    my mail : tqp_vn@yahoo.com

    Reply
  • Maybe someone else already mentioned this, but...

    Posted by Legacy on 08/06/2001 12:00am

    Originally posted by: ToneWare

    On the NT network, the following syntax can be used to send a message to any user currently logged in:

    net send username Type the message here

    Here username is the person's network userid, and
    "Type the message here" is a variable length string without delimiters. There is a limit to the string length, but I haven't actually counted chars to find it!

    We use this built-in feature at work all the time. When something changes, breaks, or comes up, I can zip off a net send and notify selected team members immediately. Of course, we never, ever use net send for personal messages :)

    Reply
  • anonymous popup ???

    Posted by Legacy on 05/09/2001 12:00am

    Originally posted by: chiasa

    Can I send anonymous popup with this program
    Can you help me?

    Reply
  • I want to know how can i receive the winpopup message in NT ?

    Posted by Legacy on 01/02/2001 12:00am

    Originally posted by: ctianh

    I want to make a program which can receive the winpopup in the NT or Win2000 , Thank you !
    

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Event Date: April 15, 2014 The ability to effectively set sales goals, assign quotas and territories, bring new people on board and quickly make adjustments to the sales force is often crucial to success--and to the field experience! But for sales operations leaders, managing the administrative processes, systems, data and various departments to get it all right can often be difficult, inefficient and manually intensive. Register for this webinar and learn how you can: Align sales goals, quotas and …

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds