共用方式為


3.1.4.30 RStartServiceA (Opnum 31)

The RStartServiceA method starts a specified service.

 DWORD RStartServiceA(
   [in] SC_RPC_HANDLE hService,
   [in, range(0, SC_MAX_ARGUMENTS)] 
     DWORD argc,
   [in, unique, size_is(argc)] LPSTRING_PTRSA argv
 );

hService: An SC_RPC_HANDLE (section 2.2.4) that defines the handle to the service record that MUST have been created previously, using one of the open methods specified in section 3.1.4. The SERVICE_START access right MUST have been granted to the caller when the RPC context handle was created.

argc: The number of argument strings in the argv array. If argv is NULL, this parameter MAY be zero.

argv: A pointer to a buffer that contains an array of pointers to null-terminated ANSI strings that are passed as arguments to the service.

Return Values: The method returns 0x00000000 (ERROR_SUCCESS) on success; otherwise, it returns one of the following error codes.<46>

Return value/code

Description

2

ERROR_FILE_NOT_FOUND

The system cannot find the file specified.

3

ERROR_PATH_NOT_FOUND

The system cannot find the path specified.

5

ERROR_ACCESS_DENIED

The SERVICE_START access right had not been granted to the caller when the RPC context handle to the service was created.

6

ERROR_INVALID_HANDLE

The handle is no longer valid.

87

ERROR_INVALID_PARAMETER

A parameter that was specified is invalid.

1053

ERROR_SERVICE_REQUEST_TIMEOUT

The process for the service was started, but it did not respond within an implementation-specific time-out.<47>

1054

ERROR_SERVICE_NO_THREAD

A thread could not be created for the service.

1055

ERROR_SERVICE_DATABASE_LOCKED

The service database is locked by the call to the RLockServiceDatabase (section 3.1.4.4) method.<48>

1056

ERROR_SERVICE_ALREADY_RUNNING

The ServiceStatus.dwCurrentState in the service record is not set to SERVICE_STOPPED.

1058

ERROR_SERVICE_DISABLED

The service cannot be started because the Start field in the service record is set to SERVICE_DISABLED.

1068

ERROR_SERVICE_DEPENDENCY_FAIL

The specified service depends on another service that has failed to start.

1069

ERROR_SERVICE_LOGON_FAILED

The service did not start due to a logon failure.

1072

ERROR_SERVICE_MARKED_FOR_DELETE

The RDeleteService method has been called for the service record identified by the hService parameter.

1075

ERROR_SERVICE_DEPENDENCY_DELETED

The specified service depends on a service that does not exist or has been marked for deletion.

1115

ERROR_SHUTDOWN_IN_PROGRESS

The system is shutting down.

In response to this request from the client, for a successful operation the server MUST start the service using the information from the service record identified by the hService parameter and pass the arguments specified in the argv parameter as part of the service launch command.

If argv is not NULL, the client SHOULD set the first element in argv to the name of the service.

The server MUST ignore argv for service records with Type equal to SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER.

The server MUST set the ServiceStatus.dwCurrentState in the service record, as specified in SERVICE_STATUS (section 2.2.47), to SERVICE_START_PENDING.

The server MUST set the ServiceStatus.dwControlsAccepted in the service record, as specified in SERVICE_STATUS, to none (zero).

The server MUST set the ServiceStatus.dwCheckPoint in the service record, as specified in SERVICE_STATUS, to zero.

The server MUST set the ServiceStatus.dwWaitHint in the service record, as specified in SERVICE_STATUS, to 2 seconds.

The server MUST return ERROR_SERVICE_NO_THREAD if it is unable to create a new thread for the service process.

If argv does not contain as many non-NULL pointers as indicated by argc, the server MUST fail the call with ERROR_INVALID_PARAMETER (87).