- Windows Service Restart operation with Parameters
- Posted by Anand CS on October 8th, 2003
Hi All
I have a question regarding Windows Service restart operation
In creating the service Ive used CreateService API passing it
"C:\SomeDir\test.ext Param1 Param2" as the executable path with my
parameters.
The service starts fine but when I try to restart the service via the
control panel "restart" button, it seems like it doesnt pass the
parameters again
and my program doesnt start due to the absense of the parameters.
Can anybody explain what mistake Im making here and if so how to
rectify it
Any help is appreciated.
Anand
- Posted by poppyto on October 8th, 2003
Hi
The services use parameters at the first start (it calls main at first
start)
So if you want to retreive your parameters, use a global buffer
and it will be available until service isn't killed
Stef++
"Anand CS" <anand_fds@yahoo.com> a écrit dans le message de news:
7cccd2d3.0310081154.5235b696@posting.google.com...
- Posted by K_Lee on October 11th, 2003
anand_fds@yahoo.com (Anand CS) wrote in message news:<7cccd2d3.0310081154.5235b696@posting.google. com>...
You should put the parameters in registry, on restart
just get it back from the registry.
Link to Apache service_ctrl() code.
http://www.slink-software.com/W/SrcD....28.sdoc/N_106
VOID WINAPI service_ctrl(DWORD dwCtrlCode)
{
switch(dwCtrlCode)
{
// Stop the service.
//
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, NULL,
"Service Stop/Shutdown signaled, shutting down server.");
ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 15000);
ap_start_shutdown();
break;
case SERVICE_APACHE_RESTART:
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, NULL,
"Service Restart signaled, shutting down server.");
ReportStatusToSCMgr(SERVICE_START_PENDING, NO_ERROR, 15000);
ap_start_restart(1);
break;
// Update the service status.
//
case SERVICE_CONTROL_INTERROGATE:
ReportStatusToSCMgr(globdat.ssStatus.dwCurrentStat e, NO_ERROR, 0);
break;
// invalid control code, ignored
//
default:
break;
- restart service (Microsoft Windows) by coconutt
- How ro Find Number of Parameters & Type of Parameters of functions exported by a DLL (Drivers) by vikrantkpr@yahoo.com
- Automatically Restart a Service? (Software & Applications) by Curt
- Monitor Service Control Manager operation from a driver (Drivers) by Omer
- Please help Windows update command line parameters (Computers & Technology) by cromi

