From: Iain Patterson Date: Mon, 2 Mar 2015 11:02:06 +0000 (+0000) Subject: Added nssm_imagepath() and nssm_unquoted_imagepath(). X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=4c25687ee744780127150e22640df47931d139a9;p=nssm.git Added nssm_imagepath() and nssm_unquoted_imagepath(). Functions to retrieve the path to nssm.exe both with and without path quoting. --- diff --git a/nssm.cpp b/nssm.cpp index 7eef69d..ddd1561 100644 --- a/nssm.cpp +++ b/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) { /* diff --git a/nssm.h b/nssm.h index f95391d..911804f 100644 --- a/nssm.h +++ b/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