diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-05-11 00:27:54 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-05-11 00:27:54 +0300 |
commit | 87300e1eeb419d8d5e027779d2d89c4a860a39de (patch) | |
tree | ff697ca8ed48fe9a8403994647a5321ad2957ba9 /utils/libservice/src | |
parent | utils: add README (diff) | |
download | windows7-drivers-87300e1eeb419d8d5e027779d2d89c4a860a39de.tar.gz windows7-drivers-87300e1eeb419d8d5e027779d2d89c4a860a39de.zip |
utils: add the '\file' Doxygen field
Diffstat (limited to 'utils/libservice/src')
-rw-r--r-- | utils/libservice/src/service.cpp | 31 | ||||
-rw-r--r-- | utils/libservice/src/service_handle.cpp | 1 | ||||
-rw-r--r-- | utils/libservice/src/service_manager.cpp | 1 | ||||
-rw-r--r-- | utils/libservice/src/windows_error.cpp | 1 |
4 files changed, 34 insertions, 0 deletions
diff --git a/utils/libservice/src/service.cpp b/utils/libservice/src/service.cpp index 1f7cbef..efe645f 100644 --- a/utils/libservice/src/service.cpp +++ b/utils/libservice/src/service.cpp @@ -95,6 +95,31 @@ namespace libservice throw std::system_error(ec, WinErrorCategory::get(), LIBSERVICE_ERROR_PREFIX); } } + + bool does_service_exist(const ServiceManager& mgr, + const std::string& name) + { + const auto raw = OpenService(static_cast<SC_HANDLE>(mgr), + name.c_str(), + SERVICE_QUERY_STATUS); + + if (NULL != raw) + { + ServiceHandle handle(raw); + return true; + } + + const auto ec = GetLastError(); + + switch (ec) + { + case ERROR_SERVICE_DOES_NOT_EXIST: + return false; + + default: + throw std::system_error(ec, WinErrorCategory::get(), LIBSERVICE_ERROR_PREFIX); + } + } SERVICE_STATUS_PROCESS query_service_status(const ServiceHandle& handle) { @@ -174,6 +199,12 @@ namespace libservice return Service(install_service(mgr, name, bin_path)); } + bool Service::does_exist(const ServiceManager& mgr, + const std::string& name) + { + return does_service_exist(mgr, name); + } + void Service::start() const { const auto state = query_service_state(m_handle); diff --git a/utils/libservice/src/service_handle.cpp b/utils/libservice/src/service_handle.cpp index 5356b50..21fb78c 100644 --- a/utils/libservice/src/service_handle.cpp +++ b/utils/libservice/src/service_handle.cpp @@ -1,4 +1,5 @@ /** + * \file * \author Egor Tensin <Egor.Tensin@gmail.com> * \date 2015 * \copyright This file is licensed under the terms of the MIT License. diff --git a/utils/libservice/src/service_manager.cpp b/utils/libservice/src/service_manager.cpp index 4888406..b3c0b96 100644 --- a/utils/libservice/src/service_manager.cpp +++ b/utils/libservice/src/service_manager.cpp @@ -1,4 +1,5 @@ /** + * \file * \author Egor Tensin <Egor.Tensin@gmail.com> * \date 2015 * \copyright This file is licensed under the terms of the MIT License. diff --git a/utils/libservice/src/windows_error.cpp b/utils/libservice/src/windows_error.cpp index 6cc7302..1e28345 100644 --- a/utils/libservice/src/windows_error.cpp +++ b/utils/libservice/src/windows_error.cpp @@ -1,4 +1,5 @@ /** + * \file * \author Egor Tensin <Egor.Tensin@gmail.com> * \date 2015 * \copyright This file is licensed under the terms of the MIT License. |