No navigation frame on the left?  Click here.

NetAlertRaiseEx

NetAlertRaiseEx() sends, via some intermediaries, a message to an alerter service, which in turn fires a semaphore or transmits the message to a mailslot provided by an application that has registered for receiving alerts of a certain type.

Unless you have an old LAN Manager server lying around and wasting electrons, this won't help you much: NetAlertStart(), the function which registers recipients of such alerts, is well and truly gone -- not only from the docs, but from netapi32.dll. As I said, gone. The only app registering a mailslot to receive alerts is, to my knowledge, the Messenger service, and no I don't know how it does it.

If you still wish to play around with NetAlertRaiseEx(), read the NetAlertRaise() documentation first. You will note that you have to pass a buffer which contains, in this order, a STD_ALERT struct; one of the foo_OTHER_INFO structs; and any additional data (like strings), tightly packed.

For NetAlertRaiseEx(), you pass in a buffer containing only the foo_OTHER_INFO struct, plus any strings etc. right after the struct. The sample below uses the ADMIN_OTHER_INFO struct. The alert types and event sources come from lmalert.h and lmcons.h, although you can pass just about anything for the event source. Note that the error code should be -1 if you wish your strings to be displayed instead of one of the NERR_* messages.

To see this in action: The computer generating the alert must have the Alerter and Messenger services running; a machine supposed to receive an alert must have Messenger running. For the box which calls NetAlertRaiseEx(), use Server Manager to go into the machine's properties, hit the "Alerts..." button, and add at least one recipient to the list. Afterwards, restart the Alerter service on that machine. Then, run one of these examples:

nare ADMIN MYSVC -1 alert hoo-ah "Here we go!"
nare ADMIN MYSVC 2203

nare.cpp, 2 KB