how can I make a Windows service beep?

前端 未结 5 1708
栀梦
栀梦 2020-12-06 14:23

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

相关标签:
5条回答
  • 2020-12-06 14:56

    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.

    0 讨论(0)
  • 2020-12-06 15:03

    I'd recommend creating a simple client application that polls that server to query for any problems and returns a set of status messages. Then an appropriate UI would be raised (e.g. balloon on the tray), an email sent, etc. containing any warning or failure messages.

    This way you also know that the watchdog itself is running and has network connectivity - if the watchdog dies and/or machine locks up you wouldn't otherwise know.

    It also avoids being thrown out of a window when the machine starts beeping continuously just after you go to lunch. [+1 to @mikej] :-)

    The poll period should be around half (see Nyquist sampling rate) your minimum required response time.

    0 讨论(0)
  • 2020-12-06 15:10

    Beeping doesn't seem like a good idea - it might end up driving everyone mad.... I'd also agree about the "interact with desktop" option and you set this in the services parameters see A Windows Service without a template

    0 讨论(0)
  • 2020-12-06 15:12

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

    0 讨论(0)
  • 2020-12-06 15:15

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

    0 讨论(0)
提交回复
热议问题