From: Iain Patterson Date: Tue, 24 Dec 2013 00:33:48 +0000 (+0000) Subject: Added delete_createfile_parameter(). X-Git-Tag: v2.22~117 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=aec569efa48339e6e886b1420af6bb101699d33b;p=nssm.git Added delete_createfile_parameter(). Function to remove a value related to I/O redirection from the registry. --- diff --git a/io.cpp b/io.cpp index 7dedce0..9dd21bf 100644 --- 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); } +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; diff --git a/io.h b/io.h index 41cb976..2056868 100644 --- a/io.h +++ b/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 *);