From: Sameeh Jubran <sjub...@redhat.com> Signed-off-by: Sameeh Jubran <sjub...@redhat.com> --- qga/service-win32.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/qga/service-win32.c b/qga/service-win32.c index 861f9fc..c17e0eb 100644 --- a/qga/service-win32.c +++ b/qga/service-win32.c @@ -198,20 +198,12 @@ int ga_install_service(const char *path, const char *logfile, static int uninstall_service(LPCTSTR service_name) { - SC_HANDLE manager; - SC_HANDLE service; - - manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (manager == NULL) { - printf_win_error("No handle to service control manager"); - return EXIT_FAILURE; - } + int ret = EXIT_FAILURE; + SC_HANDLE service = NULL; + ret = get_service(service_name, &service); - service = OpenService(manager, service_name, DELETE); - if (service == NULL) { - printf_win_error("No handle to service"); - CloseServiceHandle(manager); - return EXIT_FAILURE; + if (ret != EXIT_SUCCESS) { + return ret; } if (DeleteService(service) == FALSE) { @@ -221,7 +213,6 @@ static int uninstall_service(LPCTSTR service_name) } CloseServiceHandle(service); - CloseServiceHandle(manager); return EXIT_SUCCESS; } -- 2.9.4