Added get_number() helper.

Retrieve a number (specifically an unsigned long) from the registry.
Allow the value to be optional by setting the must_exist parameter.
Overload the function definition such that must_exist can be omitted.
Overload expand_parameter() like get_number().

Allow expand_parameter() to accept the optional must_exist flag.
Allow specifying output streams.

Allow starting the monitor application with one or more of stdin,
stdout and stderr redirected to a file or anything which can be
opened with CreateFile().

New registry values corresponding to CreateFile() arguments for
stdin (and analogously for stdout and stderr):

AppStdin: Path to open.
AppStdinShareMode: Sharing mode.
AppStdinCreationDisposition: Creation disposition.
AppStdinFlagsAndAtrributes: Flags and attributes.

All are optional.  If no path is given for a particular stream it
will not be redirected.  If a path is given but any of the other
values are omitted they will receive sensible defaults.
Notes on escaping quotes.

Brian Baxter points out that to install a service from the command
prompt with quotes in the options it is necessary to quote the quotes as
follows:

  nssm install service "c:\Program Files\app.exe" """C:\Path with spaces"""
Fixed missing io.cpp and io.h.

The files were inadvertently not pushed along with the stream
redirection code.

Thanks Runner Mei.
Rudimentary file versioning.

Embed file version info in the resource file so that right-clicking the
executable shows the application version.

Unfortunately the version field must be formatted in a particular way so
we can't reuse the NSSM_VERSION #define from nssm.h but instead must
create a new #define and remember to update it when making a release.

Thanks fREW Schmidt.
Fixed Control-C race.

A typo in kill_console() could cause the application to be restarted
when it was supposed to stop.

When kill_console() successfully generated a Control-C event and the
application exited, the function was supposed to return 0, indicating to
its parent function kill_process() that the application had been killed.

Due to a mistake in the test of WaitForSingleObject()'s return code,
kill_console() would instead return non-zero when the application exited
in response to Control-C.  This would lead NSSM to continue with other
methods of trying to kill the application, leading to a race when
another thread detected that the application had exited without
recognising that it had done so in response to a stop control.

Thanks Barrett Lewis.
Skip some or all methods of stopping the application.

Use the AppStopMethodSkip bit field to specify any method(s) which
should not be employed when stopping the application.
Delay report that the service is running.

Wait until the application has been running for long enough to be exempt
from restart throttling before reporting a status of SERVICE_RUNNING to
the operating system.

Thanks Tom Saul.
Try harder not to restart the application when stopping.

Try even harder to avoid race conditions whereby one thread reacts to an
application exit and performs a restart even after another thread has
committed to handling a stop control.

Thanks Runner Mei.
Updated nssm.dsp with missing dependencies.

Opening nssm.dsp in Visual Studio 2010 and accepting conversion to the
latest project format produced a project which would not build because
io.cpp, io.h, process.cpp, process.h and shlwapi.lib had not been added
to nssm.dsp.

They were present in nssm.vcproj from Visual Studio 2008 and it was
possible to load that project and convert to a format which worked.

Thanks Guy Brousseau.
Compiler food.

Silence any compiler warnings relating to the use of _(v)snprintf() -
not _(v)snprintf_s() - and type conversions.
AttachConsole() isn't available in Windows 2000.

Instead of calling AttachConsole() directory use a function pointer in
the new global imports struct.  It's safe to skip any attempt to attach
to the console when the function isn't available.
Try to throttle using a critical section.

The first implementation of service restart throttling used a condition
variable in a critical section to sleep for the required amount of time.
The implementation was changed to use a waitable timer because Windows
2000 does not support SleepConditionVariableCS() or
WakeConditionVariable().

Since we are now using LoadLibrary() and GetProcAddress() to use newer
functions dynamically without having to build OS-specific binaries, we
can now use a critical section where it's supported and fall back to a
waitable timer when running on Windows 2000.
Fix tabbing between GUI fields.

The tab key didn't switch between fields in the GUI because we didn't
insert a call to IsDialogMessage() in the message loop.
NSSM 2.17.
Typos and formatting etc.
Calculate service stop wait hint correctly.

The wait hint when changing the service status to stopped failed to take
into account the grace period after sending a Control-C event.  It also
failed to consider the case where one or more stop methods were
disabled.
Added override_milliseconds() helper.

Helper function to retrieve a REG_DWORD value from the registry and
assign it to a variable, substituting a default value if the registry
entry is invalid or missing.  The function is specifically tailored
toward setting a value in milliseconds, hence the name.
Use override_milliseconds() to find throttle restart delay.

Use the new override_milliseconds() helper to find the override for the
amount of time to wait when throttling restarts.