views:

27

answers:

2

i have a window service program and i need to start another executable from it ,but non of the functions are executed in SvcMain. I searched for the solution but found somewhere written that the initialization should be completed in less than one second or else it wont execute so was the failure of my createprocess they say for this to work you need to set SetServiceStatus to service_start_pending, but i cant find any document to illustrate it. how can i do this?

A: 

Try running a secondary thread from SvcMain and let that thread do the job of starting external executable.

joekoyote
do i need to report status every time from secondary thread???
Maybe I misunderstood your needs. You can describe them in more details in your original questions so that people understand what exactly you are trying to do.
joekoyote
A: 

Basically, it's as easy as it sounds. Before you call CreateProcess, create a SERVICE_STATUS object, set the SERVICE_STATUS.dwCurrentState to SERVICE_START_PENDING, and call SetServiceStatus(handle_to_your_service, &the_service_status); .

It's probably easiest to make the SERVICE_STATUS object a global. You'll be calling SetServiceStatus more than once, and most of the members will remain constant over time. E.g. .dwServiceType shouldn't change at all, and .dwControlsAccepted usually doesn't.

MSalters