4.2.2.1 Stopping the Transaction Manager Service
To restart the transaction manager on the remote machine, the Management Client established a Service Control Manager Remote Protocol [MS-SCMR] connection with the remote machine (for example, Machine2) and sends an ROpenSCManagerW call with the following values for the parameters.
-
lpMachineName = L"Machine2" lpDatabaseName = SERVICES_ACTIVE_DATABASE dwDesiredAccess = 0x00000001 // SC_MANAGER_CONNECT lpScMgrHandle = NULL
On receiving this request from the client, the server opens the handle to the SCM database with read access and returns from the method with an error code of 0 and the pointer to the opened handle in the lpScHandle parameter of the response.
The client then uses the handle returned in lpScHandle to open the transaction manager service with stop access by sending an RGetServiceDisplayNameW call with the following values for the parameters.
-
hSCManager = Handle returned in the lpScMgrHandle parameter of the previous server response. lpServiceName = L"MSDTC" dwDesiredAccess = 0x00000020 // SERVICE_STOP lpScHandle = NULL
Upon receiving this request from the client, the server queries the SCM database for the service named "MSDTC" and returns from the method with an error code of 0, and the pointer to the opened handle in the lpScHandle parameter of the response.
The client then uses the handle returned in lpScHandle to stop the transaction manager service by sending an RControlServiceExW call with the following values for the parameters.
-
hScHandle = Handle returned in the lpScHandle parameter of the previous server response. dwControl = 0x00000001 // SERVICE_CONTROL_STOP lpSvcStatus = NULL
On receiving this request from the client, the server uses the handle to stop the service and returns from the method with an error code of 0 and the pointer to the last reported service status in the lpSvcStatus parameter of the response.
The client closes the service handle by sending an RCloseServiceHandle with the following values for the parameters.
-
hScHandle = Handle returned in the lpScHandle parameter of the previous server response.
On receiving this request from the client, the server closes the handle to the service and returns from the method with an error code of 0.
The client closes the SCM database by sending an RCloseServiceHandle with the following values for the parameters.
-
hSCManager = Handle returned in the lpScMgrHandle parameter of the previous server response.
On receiving this request from the client, the server closes the handle to the open SCM database and returns from the method with an error code of 0.