Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Моя Пояснительная записка.doc
Скачиваний:
3
Добавлен:
10.09.2019
Размер:
581.12 Кб
Скачать

3. Algorithm of the client program

Fig. 3.1 - Algorithm of Client Program

The client program requests the data from user, check it, send it to service via named channels – pipes, and reads a reply from service.

The algorithm of client program is following:

  • Wait user input

Waits user.

  • Create file

Creates file via CreateFile function.

  • . Modify file to pipe

Calls SetNamedPipeHandleState for created file with PIPE_READMODE_MESSAGE parameter.

  • Get User data

Reads data from user.

  • Write data to pipe, flush buffers

Writes data to pipe via WriteFile function, and calls FlushBuffers function.

  • . Read reply from service

Reads reply from service from pipe.

  • Close pipe

Calls CloseHandler for pipe handler.

4. Implementation of service program

StartServiceCtrlDispatcher - connects the main thread of a service process to the service control manager, which causes the thread to be the service control dispatcher thread for the calling process [msdn].

RegisterServiceCtrlHandler - function to register a function to handle its service control requests [msdn].

SetSystemTime - sets the current system time and date [msdn].

CreateNamedPipe - creates an instance of a named pipe and returns a handle for subsequent pipe operations [msdn].

SetServiceStatus - updates the service control manager's status information for the calling service [msdn].

CreateEvent - creates or opens a named or unnamed event object [msdn].

WaitForSingleObject - returns when the specified object is in the signaled state or the time-out interval elapses [msdn].

WriteFile - writes data to a file at the position specified by the file pointer. This function is designed for both synchronous and asynchronous operation. [msdn].

ReadFile - reads data from a file, starting at the position that the file pointer indicates. [msdn].

CloseHandle - closes an open object handle [msdn].

ResetEvent - sets the specified event object to the no signaled state [msdn].

SetEvent - sets the specified event object to the signaled state [msdn].

SetServiceStatus - updates the service control manager's status information for the calling service [msdn].

ServiceControlHandler – function to control service run-time [msdn].

StartServiceq – service main function [msdn].

_tmain – funtion, that calls StartServiceCtrlDispatcher() for service [msdn].

5. Implementation of service management program

OpenSCManager - establishes a connection to the service control manager on the specified computer and opens the specified service control manager database [msdn].

CreateService - creates a service object and adds it to the specified service control manager database [msdn].

CloseServiceHandle - closes a handle to a service control manager or service object [msdn].

QueryServiceStatus - retrieves the current status of the specified service [msdn].

ControlService - sends a control code to a service [msdn].

StartService - starts a service [msdn].

QueryServiceConfig - retrieves the configuration parameters of the specified service [msdn].

ChangeServiceConfig - changes the configuration parameters of a service [msdn].

_tmain – interacts with user.