function starts the execution of a service.
| SC_HANDLE hService,
||// handle of service
| DWORD dwNumServiceArgs,
||// number of arguments
| LPCTSTR *lpServiceArgVectors
||// address of array of argument string pointers
Identifies the service. This handle is returned by the OpenService
function, and it must have SERVICE_START access.
Specifies the number of argument strings in the lpServiceArgVectors
array. If lpServiceArgVectors
is NULL, this parameter can be zero.
Points to an array of pointers that point to null-terminated argument strings
passed to a service. Driver services do not receive these arguments. If no
arguments are passed to the service being started, this parameter can be NULL. The
service accesses these arguments through its ServiceMain
function. Note that in the array of arguments passed to the ServiceMain
function, the first argument (argv) is the name of the service by default,
followed by the arguments, if any, in the lpServiceArgVectors
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error
information, call GetLastError
The following error codes can be set by the service control manager. Others
can be set by the registry functions that are called by the service control
||The specified handle was not opened with SERVICE_START access.
||The specified handle is invalid.
||The service binary file could not be found.
||An instance of the service is already running.
||The database is locked.
||The service depends on a service that does not exist or has been marked for
||The service depends on another service that has failed to start.
||The service has been disabled.
||The service could not be logged on.
||The service has been marked for deletion.
||A thread could not be created for the Win32 service.
||The service did not respond to the start request in a timely fashion.
When a driver service is started, the StartService
function does not return until the device driver has finished initializing.
When a service is started, the service control manager spawns the service
process, if necessary. If the specified service shares a process with other
services, the required process may already exist. The StartService
function does not wait for the first status update from the new service
(which may take a while). Instead, it returns when the service control manager
receives notification from the service control dispatcher that the ServiceMain
thread for this service was created successfully.
The service control manager sets the following default status values before
returning from StartService
- Current state of the service is set to SERVICE_START_PENDING.
- Controls accepted is set to none (zero).
- The CheckPoint value is set to zero.
- The WaitHint time is set to 2 seconds.
The calling process can determine if the new service has finished its
initialization by calling the QueryServiceStatus
function periodically to query the service's status.
A service cannot call StartService
during initialization. The reason is that the Service Control Manager locks
the service control database during initialization, so a call to StartService
will block. Once the service reports to the Service Control Manager that it
has successfully started, it can call StartService
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages
- Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database