0

How to make a program which beeps every 1 second in ATL.

I've tried to made a new ATL project (Service EXE) and in this method :

ProjectNameModule::ServiceMain(...){
    Beep(1000,50);
    //...
}

I've included this line

Beep(1000,50);

But running this, wouldn't give the expected result.

Any brilliant idea, please?

Roman R.
  • 68,205
  • 6
  • 94
  • 158
ABCmo
  • 239
  • 1
  • 6
  • 16
  • I could be wrong, but i think Beep-ing in a service is just impossible (i vaguely remember to have tried it myself). – deviantfan Mar 02 '14 at 00:39
  • try `Beep(1000, 60 * 1000);` – Iłya Bursov Mar 02 '14 at 00:39
  • @deviantfan, because, the compiler haven't displayed any compilation error. Can you please advice me a good tutorial or book for building **Service EXE** ATL applications? Because, from where I'm learning this, it's very complex and hard to understand. – ABCmo Mar 02 '14 at 00:44
  • I found my thing again, it really does not beep just because it´s a service (in my case, no ATL is involved). It compiles fine too, the compiler won´t recognize such problems. Book etc.: As i have very little experience etc. with ATL, sorry, i can´t recommend you anything. – deviantfan Mar 02 '14 at 00:52
  • A service runs in session 0, isolated from the user session. Where [nobody can hear it scream](http://stackoverflow.com/questions/1286194/how-can-i-make-a-windows-service-beep). – Hans Passant Mar 02 '14 at 11:44
  • @HansPassant, Can you please advice me a good tutorial or book for building Service EXE ATL applications? Because, from where I'm learning this, it's very complex and hard to understand. – ABCmo Mar 02 '14 at 12:12
  • @ABCmo: You're confusing two concepts. The basic rules for a service apply to all services regardless of the language/libraries/frameworks used to develop them. If you wrote a service in Visual COBOL, you still can't beep. ATL is irrelevant. – MSalters Mar 04 '14 at 13:43

1 Answers1

1

ATL Service application, created from template, does not run as service until explicitly switched.

You need to run from command line: MyProject.exe /service and this will create the actual service. Then you start the service from management console etc., or it is started when external application requested COM object hosted by this service/application.

Service is unregistered with /unregserver or /regserver, in the latter case the application hosts COM classes from regular application, as opposed to service.

See also: Media player as windows service

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks for your answer, running `MyProject.exe /Service` runs successfully, but, when I look into Windows Task Manager, MyProject.exe isn't in! – ABCmo Mar 02 '14 at 11:40
  • As I said, this **registers**, not starts the service. You can find your service running services.msc from Start Menu, Run. – Roman R. Mar 02 '14 at 11:45
  • I've built a service which runs correctly. Running the `MyProject.exe /service` doesn't create the service, did I misconfigured service? – ABCmo Mar 05 '14 at 16:59