- Mark service for delete in the registry.
authorEric Kohl <eric.kohl@reactos.org>
Tue, 1 Nov 2005 13:52:22 +0000 (13:52 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 1 Nov 2005 13:52:22 +0000 (13:52 +0000)
svn path=/trunk/; revision=18930

reactos/subsys/system/services/config.c
reactos/subsys/system/services/database.c
reactos/subsys/system/services/services.h

index 3e406f7..37451db 100644 (file)
 \r
 /* FUNCTIONS *****************************************************************/\r
 \r
+\r
+DWORD\r
+ScmOpenServiceKey(LPWSTR lpServiceName,\r
+                  REGSAM samDesired,\r
+                  PHKEY phKey)\r
+{\r
+    HKEY hServicesKey = NULL;\r
+    DWORD dwError;\r
+\r
+    *phKey = NULL;\r
+\r
+    dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,\r
+                            L"System\\CurrentControlSet\\Services",\r
+                            0,\r
+                            KEY_READ,\r
+                            &hServicesKey);\r
+    if (dwError != ERROR_SUCCESS)\r
+        return dwError;\r
+\r
+    dwError = RegOpenKeyExW(hServicesKey,\r
+                            lpServiceName,\r
+                            0,\r
+                            samDesired,\r
+                            phKey);\r
+\r
+    RegCloseKey(hServicesKey);\r
+\r
+    return dwError;\r
+}\r
+\r
+\r
 DWORD\r
 ScmWriteDependencies(HKEY hServiceKey,\r
                      LPWSTR lpDependencies,\r
index 1e1179e..ef57307 100644 (file)
@@ -987,9 +987,28 @@ ScmAutoStartServices(VOID)
 DWORD
 ScmMarkServiceForDelete(PSERVICE pService)
 {
-    DPRINT1("ScmMarkServiceForDelete() called\n");
+    HKEY hServiceKey = NULL;
+    DWORD dwValue = 1;
+    DWORD dwError;
 
-    return ERROR_SUCCESS;
+    DPRINT("ScmMarkServiceForDelete() called\n");
+
+    dwError = ScmOpenServiceKey(pService->lpServiceName,
+                                KEY_WRITE,
+                                &hServiceKey);
+    if (dwError != ERROR_SUCCESS)
+        return dwError;
+
+    dwError = RegSetValueExW(hServiceKey,
+                             L"DeleteFlag",
+                             0,
+                             REG_DWORD,
+                             (LPBYTE)&dwValue,
+                             sizeof(DWORD));
+
+    RegCloseKey(hServiceKey);
+
+    return dwError;
 }
 
 /* EOF */
index 2e65d89..4fdd57b 100644 (file)
@@ -43,6 +43,10 @@ extern BOOL ScmShutdown;
 
 /* config.c */
 
+DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
+                        REGSAM samDesired,
+                        PHKEY phKey);
+
 DWORD ScmWriteDependencies(HKEY hServiceKey,
                            LPWSTR lpDependencies,
                            DWORD dwDependenciesLength);