Quellcode durchsuchen

Added nssm_imagepath() and nssm_unquoted_imagepath().

Functions to retrieve the path to nssm.exe both with and without path
quoting.
Iain Patterson vor 9 Jahren
Ursprung
Commit
4c25687ee7
2 geänderte Dateien mit 18 neuen und 0 gelöschten Zeilen
  1. 16 0
      nssm.cpp
  2. 2 0
      nssm.h

+ 16 - 0
nssm.cpp

@@ -4,6 +4,9 @@ extern unsigned long tls_index;
 extern bool is_admin;
 extern imports_t imports;
 
+static TCHAR unquoted_imagepath[PATH_LENGTH];
+static TCHAR imagepath[PATH_LENGTH];
+
 /* Are two strings case-insensitively equivalent? */
 int str_equiv(const TCHAR *a, const TCHAR *b) {
   size_t len = _tcslen(a);
@@ -100,6 +103,14 @@ int num_cpus() {
   return (int) i;
 }
 
+const TCHAR *nssm_unquoted_imagepath() {
+  return unquoted_imagepath;
+}
+
+const TCHAR *nssm_imagepath() {
+  return imagepath;
+}
+
 int _tmain(int argc, TCHAR **argv) {
   check_console();
 
@@ -118,6 +129,11 @@ int _tmain(int argc, TCHAR **argv) {
   /* Set up function pointers. */
   if (get_imports()) exit(111);
 
+  /* Remember our path for later. */
+  GetModuleFileName(0, unquoted_imagepath, _countof(unquoted_imagepath));
+  GetModuleFileName(0, imagepath, _countof(imagepath));
+  PathQuoteSpaces(imagepath);
+
   /* Elevate */
   if (argc > 1) {
     /*

+ 2 - 0
nssm.h

@@ -60,6 +60,8 @@ int str_number(const TCHAR *, unsigned long *, TCHAR **);
 int str_number(const TCHAR *, unsigned long *);
 int num_cpus();
 int usage(int);
+const TCHAR *nssm_unquoted_imagepath();
+const TCHAR *nssm_imagepath();
 
 #define NSSM _T("NSSM")
 #ifdef _WIN64