Added nssm_exe().
[nssm.git] / nssm.cpp
index 647ea40..3df55bc 100644 (file)
--- a/nssm.cpp
+++ b/nssm.cpp
@@ -6,6 +6,7 @@ extern imports_t imports;
 \r
 static TCHAR unquoted_imagepath[PATH_LENGTH];\r
 static TCHAR imagepath[PATH_LENGTH];\r
+static TCHAR imageargv0[PATH_LENGTH];\r
 \r
 /* Are two strings case-insensitively equivalent? */\r
 int str_equiv(const TCHAR *a, const TCHAR *b) {\r
@@ -104,6 +105,10 @@ const TCHAR *nssm_imagepath() {
   return imagepath;\r
 }\r
 \r
+const TCHAR *nssm_exe() {\r
+  return imageargv0;\r
+}\r
+\r
 int _tmain(int argc, TCHAR **argv) {\r
   check_console();\r
 \r
@@ -123,6 +128,8 @@ int _tmain(int argc, TCHAR **argv) {
   if (get_imports()) exit(111);\r
 \r
   /* Remember our path for later. */\r
+  _sntprintf_s(imageargv0, _countof(imageargv0), _TRUNCATE, _T("%s"), argv[0]);\r
+  PathQuoteSpaces(imageargv0);\r
   GetModuleFileName(0, unquoted_imagepath, _countof(unquoted_imagepath));\r
   GetModuleFileName(0, imagepath, _countof(imagepath));\r
   PathQuoteSpaces(imagepath);\r