Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making A VC++ Dialog App Run as a service

Status
Not open for further replies.

myperu

Programmer
May 24, 2003
3
0
0
US
I have a Dialog based appication which I start from a
a short cut on the desktop. To run the application,
I push a start button on the Dialog Box. The onStart event
method does some initialization and then connects to a database.

I want the application to start as a Windows NT
service and begin the intitalization without anyone
pressing the start button. I am using MFC on VC++ 6.0.
 
>> I want the application to start as a Windows NT
service

Well normally NT services are console programs, but I guess a MFC dialog app would work too...

You will have to call StartServiceCtrlDispatcher in your app's InitInstance function. As well as create a ServiceMain handler and a control handler. Take a look at the Platform SDK documentation "About Services" for more information.

>> begin the intitalization without anyone pressing the start button.

Well, if you put all the initialization code in the handler for a button click, then expect that functionality not to occur until you click the button.

What I mean by that is, if you want code to execute at the beginning of your program, put it at the beginning of your program.

[sub]I REALLY hope that helps.[/sub]
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top