Browse Source

Added delete_createfile_parameter().

Function to remove a value related to I/O redirection from the registry.
Iain Patterson 8 years ago
parent
commit
aec569efa4
2 changed files with 13 additions and 0 deletions
  1. 12 0
      io.cpp
  2. 1 0
      io.h

+ 12 - 0
io.cpp

@@ -61,6 +61,18 @@ int set_createfile_parameter(HKEY key, TCHAR *prefix, TCHAR *suffix, unsigned lo
   return set_number(key, value, number);
 }
 
+int delete_createfile_parameter(HKEY key, TCHAR *prefix, TCHAR *suffix) {
+  TCHAR value[NSSM_STDIO_LENGTH];
+
+  if (_sntprintf_s(value, _countof(value), _TRUNCATE, _T("%s%s"), prefix, suffix) < 0) {
+    log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, suffix, _T("delete_createfile_parameter()"), 0);
+    return 1;
+  }
+
+  if (RegDeleteValue(key, value)) return 0;
+  return 1;
+}
+
 HANDLE append_to_file(TCHAR *path, unsigned long sharing, SECURITY_ATTRIBUTES *attributes, unsigned long disposition, unsigned long flags) {
   HANDLE ret;
 

+ 1 - 0
io.h

@@ -13,6 +13,7 @@
 
 int get_createfile_parameters(HKEY, TCHAR *, TCHAR *, unsigned long *, unsigned long, unsigned long *, unsigned long, unsigned long *, unsigned long);
 int set_createfile_parameter(HKEY, TCHAR *, TCHAR *, unsigned long);
+int delete_createfile_parameter(HKEY, TCHAR *, TCHAR *);
 HANDLE append_to_file(TCHAR *, unsigned long, SECURITY_ATTRIBUTES *, unsigned long, unsigned long);
 void rotate_file(TCHAR *, TCHAR *, unsigned long, unsigned long, unsigned long);
 int get_output_handles(nssm_service_t *, HKEY, STARTUPINFO *);