advapi/service: Simplify DeleteService by using RegDeleteTree.
This commit is contained in:
parent
c15245d9cc
commit
05fec6c871
|
@ -1422,11 +1422,6 @@ CreateServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
|
||||||
BOOL WINAPI DeleteService( SC_HANDLE hService )
|
BOOL WINAPI DeleteService( SC_HANDLE hService )
|
||||||
{
|
{
|
||||||
struct sc_service *hsvc;
|
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);
|
hsvc = sc_handle_get_handle_data(hService, SC_HTYPE_SERVICE);
|
||||||
if (!hsvc)
|
if (!hsvc)
|
||||||
|
@ -1434,25 +1429,15 @@ BOOL WINAPI DeleteService( SC_HANDLE hService )
|
||||||
SetLastError( ERROR_INVALID_HANDLE );
|
SetLastError( ERROR_INVALID_HANDLE );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
hKey = hsvc->hkey;
|
|
||||||
|
|
||||||
size = MAX_PATH+1;
|
/* Close the key to the service */
|
||||||
/* Clean out the values */
|
RegCloseKey(hsvc->hkey);
|
||||||
rc = RegEnumValueW(hKey, index, valname,&size,0,0,0,0);
|
|
||||||
while (rc == ERROR_SUCCESS)
|
/* Delete the service under the Service Control Manager key */
|
||||||
{
|
RegDeleteTreeW(hsvc->scm->hkey, hsvc->name);
|
||||||
RegDeleteValueW(hKey,valname);
|
|
||||||
index++;
|
|
||||||
size = MAX_PATH+1;
|
|
||||||
rc = RegEnumValueW(hKey, index, valname, &size,0,0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
hsvc->hkey = NULL;
|
hsvc->hkey = NULL;
|
||||||
|
|
||||||
/* delete the key */
|
|
||||||
RegDeleteKeyW(hsvc->scm->hkey, hsvc->name);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue