From 05fec6c871f0c8c44cfb8752a81164c57f00a125 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Wed, 11 Jul 2007 19:36:00 +0200 Subject: [PATCH] advapi/service: Simplify DeleteService by using RegDeleteTree. --- dlls/advapi32/service.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index 7bded192949..462abdb1e29 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -1422,11 +1422,6 @@ CreateServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, BOOL WINAPI DeleteService( SC_HANDLE hService ) { struct sc_service *hsvc; - HKEY hKey; - WCHAR valname[MAX_PATH+1]; - INT index = 0; - LONG rc; - DWORD size; hsvc = sc_handle_get_handle_data(hService, SC_HTYPE_SERVICE); if (!hsvc) @@ -1434,25 +1429,15 @@ BOOL WINAPI DeleteService( SC_HANDLE hService ) SetLastError( ERROR_INVALID_HANDLE ); return FALSE; } - hKey = hsvc->hkey; - size = MAX_PATH+1; - /* Clean out the values */ - rc = RegEnumValueW(hKey, index, valname,&size,0,0,0,0); - while (rc == ERROR_SUCCESS) - { - RegDeleteValueW(hKey,valname); - index++; - size = MAX_PATH+1; - rc = RegEnumValueW(hKey, index, valname, &size,0,0,0,0); - } + /* Close the key to the service */ + RegCloseKey(hsvc->hkey); + + /* Delete the service under the Service Control Manager key */ + RegDeleteTreeW(hsvc->scm->hkey, hsvc->name); - RegCloseKey(hKey); hsvc->hkey = NULL; - /* delete the key */ - RegDeleteKeyW(hsvc->scm->hkey, hsvc->name); - return TRUE; }