[ntp:questions] Re: Specifying command line parameters for ntpd running as a w2k service?

Terje Mathisen terje.mathisen at hda.hydro.com
Fri Jan 21 16:49:15 UTC 2005


Martin Burnicki wrote:
> mayer at gis.net wrote:
> 
>>No, there is no specific key you can set for a service to automatically
>>read and pass. The basic design of services assumes a Windows-centric
>>view where all keys can be read directly out of the registry and it
>>doesn't need to pass any command line options. Getting around this
>>problem is a chore.
> 
> 
> I'm currently looking at how this could be implemented the best way.
> 
> Assuming we already have added a Windows registry key which contains a
> string of command line parameters, e.g. "-g -L" OR "-gL".
> 
> Normally if ntpd starts as service it would read the registry key and
> evaluate the contents of the registry key string. 
> 
> However, ntpd can also be run from a command line. Depending on the actual
> command line parameters, it can stay in the foreground, or start itself as
> service.
> 
> What would be the preferred behaviour in this case:
> 
> - get the arguments from the command line, and read the parameters from the
> registry only if does not stay in the foreground
> 
> - always get arguments from the registry, then from the command line, which
> made it possible to override arguments from the registry
> 
> - anything else

My suggestion would be for the ntpd program to default to reading the 
registry key, unless at least one paramter is given. In that case use 
only the parameters specified on the command line.

I.e.:

   LPSTR cmd = GetCommandLine();
   LPWSTR * pstr = CommandLineToArgV(cmd, &NrOfArgs);

   if (NrOfArgs == 0) {
      LONG res = RegQueryValue(... &buffer)
      pstr = CommandLineToArgV(buffer, &NrOfArgs);
   }
   ... use parameters in pstr here!

Terje

-- 
- <Terje.Mathisen at hda.hydro.com>
"almost all programming can be viewed as an exercise in caching"



More information about the questions mailing list