How can I make a Windows service beep?

I have a service that acts as a watchdog for multiple applications / servers. There are no user sessions on this computer. I would like the watchdog to sound on the internal speaker if something goes wrong (it will be my turn to fix what he complains about)

when I try to use the Beep () API for Windows, nothing happens - I suspect the problem is that the service session is not allowed to make noise?

Can I do this job? any other ideas on how to do the service, warn me?

-CG

+3
source share
5 answers

Call CreateFile on \ device \ beep, then send IOCTL_BEEP_SET (for more details see http://www.koders.com/c/fidFEC3527B9D951559D62722A9C0C603863106CA9B.aspx )

+6
source

This may work if you allow it to interact with the desktop (option configurable somewhere, I can’t remember where).

But, personally, I would be sent this email.

Although, perhaps you could use the Task Planning API to schedule a task for yourself, so the next time you log in, you can see it.

I dont know; You have several options. I would avoid beeps.

+1
source

Try sending the char "\ a" beep to the console. Not sure if this will work.

0
source

Sounding a sound does not seem like a good idea - it can make everyone crazy ... I also agree with the option "interact with a desktop computer" and you set this in the service settings, see Windows service without a template

0
source

I would recommend creating a simple client application that polls this server to request any problems and returns a set of status messages. Then, the corresponding user interface (for example, a bottle on the tray), a sent email, etc. containing warnings or error messages will be raised.

Thus, you also know that the watchdog timer itself works and has a network connection - if the watchdog timer dies and / or the machine is blocked, you do not know otherwise.

He also avoids being thrown out of the window when the machine begins to continuously make sounds right after lunch. [+1 to @mikej] :-)

The polling period should be about half (see Nyquist sampling rate ) the minimum required response time.

0
source

All Articles