X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=0b586f36cb427fdacc1d1f6dd631c79cd082bbb4;hb=e26682667e15433cad518e622c3c061840b487dd;hp=ddd1561e9f643efe9f88b4fe3c7d699e12dc8fd8;hpb=4c25687ee744780127150e22640df47931d139a9;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index ddd1561..0b586f3 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -65,16 +65,10 @@ static int elevate(int argc, TCHAR **argv, unsigned long message) { ZeroMemory(&sei, sizeof(sei)); sei.cbSize = sizeof(sei); sei.lpVerb = _T("runas"); - sei.lpFile = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, PATH_LENGTH); - if (! sei.lpFile) { - print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("GetModuleFileName()"), _T("elevate()")); - return 111; - } - GetModuleFileName(0, (TCHAR *) sei.lpFile, PATH_LENGTH); + sei.lpFile = (TCHAR *) nssm_imagepath(); TCHAR *args = (TCHAR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, EXE_LENGTH * sizeof(TCHAR)); if (! args) { - HeapFree(GetProcessHeap(), 0, (void *) sei.lpFile); print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("GetCommandLine()"), _T("elevate()")); return 111; } @@ -91,7 +85,6 @@ static int elevate(int argc, TCHAR **argv, unsigned long message) { unsigned long exitcode = 0; if (! ShellExecuteEx(&sei)) exitcode = 100; - HeapFree(GetProcessHeap(), 0, (void *) sei.lpFile); HeapFree(GetProcessHeap(), 0, (void *) args); return exitcode; }