Hi BijU,
As far as I know, there is no library nor header file to access the Windows
Time functions through an API. That leaves you with three options:
- spawn the w32tm.exe command that you need. W32tm.exe is a wrapper to
access the functions in w32time.dll
- reverse-engineer the functions provided by w32time.dll and call these from
you application
- ask Microsoft to document the w32time.dll interface
To call the functions in the dll directly, use the LoadLibrary() and
GetProcAddress() functions. Example to resync the local computer (error
handling omitted):
HMODULE h = LoadLibrary("w32time.dll");
W32TimeSyncNow pW32TimeSyncNow = (W32TimeSyncNow)GetProcAddress( h,
"W32TimeSyncNow");
int rv = (pW32TimeSyncNow)(NULL,0x01,0x03);
In case you have to support Windows2000 also, beware: Windows Time on W2K
differs completely from the implementation on XP.
I hope this helps,
Paul.
"BijU" wrote:
> Hi Paul,
> I'm a beginner with Windows Time Service.
> i have some doubts..
> from where, i can get the function definitions of Window Time Services?
> How can i use that in a program..
> which library or which header file?
>
> Please help me..
> i didn't get any grip to start my job..
>
>
> "Paul Turelinckx" wrote:
>
> > We are using the Windows time service on Windows XP to synchronize the clock
> > on our POS devices.
> > We have configured multiple networks on our POS computers (multiple local IP
> > addresses): one network is used for local traffic between the POS devices, a
> > second network is used for communication with the 'outside world'.
> >
> > The Windows time service seems to randomly use either the primary or
> > secondary network for communication with the network time server, causing the
> > time synchronization to fail when it uses the IP address for the 'local'
> > network.
> >
> > So my question is twofold:
> > 1. Is there a way to diagnose this problem? I don't see any event in
> > eventviewer when the synchronization failed.
> > 2. How can I force the time service to use a specific IP address when there
> > are multiple IP addresses configured?
> >
> > Thanks.
> >