static HWND tablist[NSSM_NUM_TABS];\r
static int selected_tab;\r
\r
-int nssm_gui(int resource, TCHAR *name) {\r
+int nssm_gui(int resource, nssm_service_t *service) {\r
/* Create window */\r
- HWND dlg = CreateDialog(0, MAKEINTRESOURCE(resource), 0, install_dlg);\r
+ HWND dlg = CreateDialogParam(0, MAKEINTRESOURCE(resource), 0, nssm_dlg, (LPARAM) service);\r
if (! dlg) {\r
popup_message(MB_OK, NSSM_GUI_CREATEDIALOG_FAILED, error_string(GetLastError()));\r
return 1;\r
ShowWindow(dlg, SW_SHOW);\r
\r
/* Set service name if given */\r
- if (name) {\r
- SetDlgItemText(dlg, IDC_NAME, name);\r
+ if (service->name[0]) {\r
+ SetDlgItemText(dlg, IDC_NAME, service->name);\r
/* No point making user click remove if the name is already entered */\r
if (resource == IDD_REMOVE) {\r
HWND button = GetDlgItem(dlg, IDC_REMOVE);\r
}\r
\r
/* Install/remove dialogue callback */\r
-INT_PTR CALLBACK install_dlg(HWND window, UINT message, WPARAM w, LPARAM l) {\r
+INT_PTR CALLBACK nssm_dlg(HWND window, UINT message, WPARAM w, LPARAM l) {\r
switch (message) {\r
/* Creating the dialogue */\r
case WM_INITDIALOG:\r
#include <commctrl.h>\r
#include "resource.h"\r
\r
-int nssm_gui(int, TCHAR *);\r
+int nssm_gui(int, nssm_service_t *);\r
void centre_window(HWND);\r
int install(HWND);\r
int remove(HWND);\r
void browse(HWND);\r
-INT_PTR CALLBACK install_dlg(HWND, UINT, WPARAM, LPARAM);\r
+INT_PTR CALLBACK nssm_dlg(HWND, UINT, WPARAM, LPARAM);\r
\r
#endif\r
\r
/* About to install the service */\r
int pre_install_service(int argc, TCHAR **argv) {\r
+ nssm_service_t *service = alloc_nssm_service();\r
+ set_nssm_service_defaults(service);\r
+ if (argc) _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]);\r
+\r
/* Show the dialogue box if we didn't give the service name and path */\r
- if (argc < 2) return nssm_gui(IDD_INSTALL, argv[0]);\r
+ if (argc < 2) return nssm_gui(IDD_INSTALL, service);\r
\r
- nssm_service_t *service = alloc_nssm_service();\r
if (! service) {\r
print_message(stderr, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("pre_install_service()"));\r
return 1;\r
}\r
-\r
- set_nssm_service_defaults(service);\r
- _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]);\r
_sntprintf_s(service->exe, _countof(service->exe), _TRUNCATE, _T("%s"), argv[1]);\r
\r
/* Arguments are optional */\r
\r
/* About to remove the service */\r
int pre_remove_service(int argc, TCHAR **argv) {\r
+ nssm_service_t *service = alloc_nssm_service();\r
+ set_nssm_service_defaults(service);\r
+ if (argc) _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]);\r
+\r
/* Show dialogue box if we didn't pass service name and "confirm" */\r
- if (argc < 2) return nssm_gui(IDD_REMOVE, argv[0]);\r
+ if (argc < 2) return nssm_gui(IDD_REMOVE, service);\r
if (str_equiv(argv[1], _T("confirm"))) {\r
- nssm_service_t *service = alloc_nssm_service();\r
- _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]);\r
int ret = remove_service(service);\r
cleanup_nssm_service(service);\r
return ret;\r