advapi/service: Simplify DeleteService by using RegDeleteTree.

This commit is contained in:
Paul Vriens 2007-07-11 19:36:00 +02:00 committed by Alexandre Julliard
parent c15245d9cc
commit 05fec6c871
1 changed files with 5 additions and 20 deletions

View File

@ -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;
}