Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I make a Windows service beep?

I've got a service that acts as a watchdog for several apps/servers. There are no user sessions on this machine. I'd like the watchdog to be capable of beeping on the internal speaker should something go wrong (that'd be my queue to go fix whatever it's complaining about)

when I try the Beep() API on Windows nothing happens - I suspect the problem is that the services session isnt permitted to make noises?

can I make this work? any other ideas for how to make the service alert me?

-CG

like image 652
stuck Avatar asked Mar 01 '23 10:03

stuck


2 Answers

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

like image 195
Ana Betts Avatar answered Mar 10 '23 09:03

Ana Betts


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

But personally, I'd have it email me.

Though maybe you could have it use the task scheduling API to schedule a task for yourself, so next time you log on you can see it.

I don't know; you've got a few options. I'd avoid beeping though.

like image 37
Noon Silk Avatar answered Mar 10 '23 10:03

Noon Silk