X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=gui.cpp;h=7955b1a15861323bda8a71b6b5595817d55a3cc4;hb=636b16d3702049145143511c6461ff20bf1f245d;hp=97c69a8da5c6ca0a96929d2e5455380eb5f8ce4d;hpb=f2ec1c0c55a6b3e8ca02b3d66b78c87fe0ac1f47;p=nssm.git diff --git a/gui.cpp b/gui.cpp index 97c69a8..7955b1a 100644 --- a/gui.cpp +++ b/gui.cpp @@ -28,6 +28,7 @@ int nssm_gui(int resource, char *name) { /* Go! */ MSG message; while (GetMessage(&message, 0, 0, 0)) { + if (IsDialogMessage(dlg, &message)) continue; TranslateMessage(&message); DispatchMessage(&message); } @@ -63,9 +64,9 @@ int install(HWND window) { if (! window) return 1; /* Check parameters in the window */ - char name[STRING_SIZE]; + char name[VALUE_LENGTH]; char exe[EXE_LENGTH]; - char flags[STRING_SIZE]; + char flags[VALUE_LENGTH]; /* Get service name */ if (! GetDlgItemText(window, IDC_NAME, name, sizeof(name))) { @@ -120,7 +121,7 @@ int remove(HWND window) { if (! window) return 1; /* Check parameters in the window */ - char name[STRING_SIZE]; + char name[VALUE_LENGTH]; /* Get service name */ if (! GetDlgItemText(window, IDC_NAME, name, sizeof(name))) { @@ -154,8 +155,8 @@ int remove(HWND window) { void browse(HWND window) { if (! window) return; - unsigned long bufsize = 256; - unsigned long len = bufsize; + size_t bufsize = 256; + size_t len = bufsize; OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); @@ -164,18 +165,18 @@ void browse(HWND window) { if (ofn.lpstrFilter) { ZeroMemory((void *) ofn.lpstrFilter, bufsize); char *localised = message_string(NSSM_GUI_BROWSE_FILTER_APPLICATIONS); - _snprintf((char *) ofn.lpstrFilter, bufsize, localised); + _snprintf_s((char *) ofn.lpstrFilter, bufsize, _TRUNCATE, localised); /* "Applications" + NULL + "*.exe" + NULL */ len = strlen(localised) + 1; LocalFree(localised); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.exe"); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, "*.exe"); /* "All files" + NULL + "*.*" + NULL */ len += 6; localised = message_string(NSSM_GUI_BROWSE_FILTER_ALL_FILES); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, localised); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, localised); len += strlen(localised) + 1; LocalFree(localised); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.*"); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, "*.*"); /* Remainder of the buffer is already zeroed */ } ofn.lpstrFile = new char[MAX_PATH];