Added delete_createfile_parameter().
authorIain Patterson <me@iain.cx>
Tue, 24 Dec 2013 00:33:48 +0000 (00:33 +0000)
committerIain Patterson <me@iain.cx>
Tue, 24 Dec 2013 09:17:47 +0000 (09:17 +0000)
Function to remove a value related to I/O redirection from the registry.

io.cpp
io.h

diff --git a/io.cpp b/io.cpp
index 7dedce0..9dd21bf 100644 (file)
--- a/io.cpp
+++ b/io.cpp
@@ -61,6 +61,18 @@ int set_createfile_parameter(HKEY key, TCHAR *prefix, TCHAR *suffix, unsigned lo
   return set_number(key, value, number);\r
 }\r
 \r
+int delete_createfile_parameter(HKEY key, TCHAR *prefix, TCHAR *suffix) {\r
+  TCHAR value[NSSM_STDIO_LENGTH];\r
+\r
+  if (_sntprintf_s(value, _countof(value), _TRUNCATE, _T("%s%s"), prefix, suffix) < 0) {\r
+    log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, suffix, _T("delete_createfile_parameter()"), 0);\r
+    return 1;\r
+  }\r
+\r
+  if (RegDeleteValue(key, value)) return 0;\r
+  return 1;\r
+}\r
+\r
 HANDLE append_to_file(TCHAR *path, unsigned long sharing, SECURITY_ATTRIBUTES *attributes, unsigned long disposition, unsigned long flags) {\r
   HANDLE ret;\r
 \r
diff --git a/io.h b/io.h
index 41cb976..2056868 100644 (file)
--- a/io.h
+++ b/io.h
@@ -13,6 +13,7 @@
 \r
 int get_createfile_parameters(HKEY, TCHAR *, TCHAR *, unsigned long *, unsigned long, unsigned long *, unsigned long, unsigned long *, unsigned long);\r
 int set_createfile_parameter(HKEY, TCHAR *, TCHAR *, unsigned long);\r
+int delete_createfile_parameter(HKEY, TCHAR *, TCHAR *);\r
 HANDLE append_to_file(TCHAR *, unsigned long, SECURITY_ATTRIBUTES *, unsigned long, unsigned long);\r
 void rotate_file(TCHAR *, TCHAR *, unsigned long, unsigned long, unsigned long);\r
 int get_output_handles(nssm_service_t *, HKEY, STARTUPINFO *);\r