From caaaa1208f29647987173f7d9bc1aa75b58757b7 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Fri, 15 Jul 2016 14:27:31 +0100 Subject: [PATCH] Added nssm_exe(). New function to retrieve argv[0]. --- nssm.cpp | 7 +++++++ nssm.h | 1 + 2 files changed, 8 insertions(+) diff --git a/nssm.cpp b/nssm.cpp index 647ea40..3df55bc 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -6,6 +6,7 @@ extern imports_t imports; static TCHAR unquoted_imagepath[PATH_LENGTH]; static TCHAR imagepath[PATH_LENGTH]; +static TCHAR imageargv0[PATH_LENGTH]; /* Are two strings case-insensitively equivalent? */ int str_equiv(const TCHAR *a, const TCHAR *b) { @@ -104,6 +105,10 @@ const TCHAR *nssm_imagepath() { return imagepath; } +const TCHAR *nssm_exe() { + return imageargv0; +} + int _tmain(int argc, TCHAR **argv) { check_console(); @@ -123,6 +128,8 @@ int _tmain(int argc, TCHAR **argv) { if (get_imports()) exit(111); /* Remember our path for later. */ + _sntprintf_s(imageargv0, _countof(imageargv0), _TRUNCATE, _T("%s"), argv[0]); + PathQuoteSpaces(imageargv0); GetModuleFileName(0, unquoted_imagepath, _countof(unquoted_imagepath)); GetModuleFileName(0, imagepath, _countof(imagepath)); PathQuoteSpaces(imagepath); diff --git a/nssm.h b/nssm.h index f500a33..118d20f 100644 --- a/nssm.h +++ b/nssm.h @@ -69,6 +69,7 @@ int num_cpus(); int usage(int); const TCHAR *nssm_unquoted_imagepath(); const TCHAR *nssm_imagepath(); +const TCHAR *nssm_exe(); #define NSSM _T("NSSM") #ifdef _WIN64 -- 2.20.1