Sending "Pop Up" Messages via NetMessageXXX Functions
This article was contributed by Phil Petree.
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
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.
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.
DownloadsDownload demo project - 30 Kb
HistoryDate Posted: January 16, 2000