I tried to sync my device (Win CE 6.0) time using SNTP. All the SNTP IOCTL
's are working except "IOCTL_SERVICE_CONTROL". When i call Service IOCTL ,
Invalid parameter error is occurring. I am using the following code
WCHAR szControlString[]=L"sync";
DWORD dwLenIn=sizeof(szControlString);
DWORD dwBytesReturned;
DeviceIoControl(hFile, IOCTL_SERVICE_CONTROL, szControlString, dwLenIn,
NULL, 0, &dwBytesReturned, NULL);
return 0;
}
and registry settings are
[HKEY_LOCAL_MACHINE\Services\TIMESVC]
"server"=multi_sz:"pool.ntp.org"
"AutoUpdate"=dword:1
"ServerRole"=dword:0
"refresh"=dword:1B7740
"recoveryrefresh"=dword:493E0
"threshold"=dword:DBBA0
"trustlocalclock"=dword:1
Even I tried by reducing the refresh and recovery time.
Following Sysgen variable are selected
SYSGEN_TIMESVC_API, SYSGEN_TIMESVC_DST and SYSGEN_TIMESVC_SNTP
Thanks,
might not give you the length that you need.
Try DWORD dwLenIn=sizeof(L"sync");
--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT Eurotech DOT com
My BLOG http://geekswithblogs.net/bruceeitman
Eurotech Inc.
www.Eurotech.com
"Salim" <Sa...@discussions.microsoft.com> wrote in message
news:5ABB8486-3A20-4FA2...@microsoft.com...
DWORD dwLenIn=sizeof(szControlString); ==> 4 which is the size of a
WCHAR pointer
DWORD dwLenIn=wcslen(szControlString); ==> size of the WCHAR string
regards
Fabrice
Le 08/03/2010 11:56, Salim a écrit :
> Hi,
>
> I tried to sync my device (Win CE 6.0) time using SNTP. All the SNTP IOCTL
> 's are working except "IOCTL_SERVICE_CONTROL". When i call Service IOCTL ,
> Invalid parameter error is occurring. I am using the following code
>
> WCHAR szControlString[]=L"sync";
> DWORD dwLenIn=sizeof(szControlString);
> DWORD dwBytesReturned;
>
> DeviceIoControl(hFile, IOCTL_SERVICE_CONTROL, szControlString, dwLenIn,
> NULL, 0,&dwBytesReturned, NULL);
--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT Eurotech DOT com
My BLOG http://geekswithblogs.net/bruceeitman
Eurotech Inc.
www.Eurotech.com
"Fabrice MOUSSET" <fabrice...@laposte.net> wrote in message
news:u9VFxlt...@TK2MSFTNGP02.phx.gbl...
I think there is a mistake with dwLenIn;
DWORD dwLenIn=sizeof(szControlString); ==> 4 which is the size of a
WCHAR pointer
DWORD dwLenIn=wcslen(szControlString); ==> size of the WCHAR string
regards
Fabrice
Le 08/03/2010 11:56, Salim a �crit :
bellow my code:
int _tmain(int argc, TCHAR *argv[], TCHAR *envp[])
{
HANDLE
hFile=CreateFile(L"NTP0:",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
WCHAR szControlString[]=L"sync";
DWORD dwLenIn=sizeof(szControlString);
DWORD dwBytesReturned;
if(INVALID_HANDLE_VALUE==hFile)
{
_tprintf(_T("NTP Driver openning error :-(\n"));
return 0;
}
_tprintf(_T("Starting NTP\n"));
DeviceIoControl(hFile, IOCTL_SERVICE_START, NULL, 0, NULL, 0, NULL,
NULL);
_tprintf(_T("Force NTP synchronization\n"));
DeviceIoControl(hFile, IOCTL_SERVICE_CONTROL, szControlString,
dwLenIn, NULL, 0, &dwBytesReturned, NULL);
CloseHandle(hFile);
return 0;
}
And the registry is like this
; Réglage du client SNTP pour forcée la mise à jour
; automatique de la date et de l'heure
[HKEY_LOCAL_MACHINE\Services\Timesvc]
"AutoUpdate"=dword:1
"ClientOnly"=dword:1
"AutoDST"=dword:1
"Trustlocalclock"=dword:0
"Refresh"=dword:48190800 ; 2 weeks
"RecoveryRefresh"=dword:1B7740 ; 30 minutes
"Threshold"=dword:5265C00 ; 1 day
"Server"="pool.ntp.org"
Hope this help
Fabrice
Le 08/03/2010 11:56, Salim a écrit :
> Hi,
>
> I tried to sync my device (Win CE 6.0) time using SNTP. All the SNTP IOCTL
> 's are working except "IOCTL_SERVICE_CONTROL". When i call Service IOCTL ,
> Invalid parameter error is occurring. I am using the following code
>
> WCHAR szControlString[]=L"sync";
> DWORD dwLenIn=sizeof(szControlString);
> DWORD dwBytesReturned;
>
> DeviceIoControl(hFile, IOCTL_SERVICE_CONTROL, szControlString, dwLenIn,
> NULL, 0,&dwBytesReturned, NULL);
Let me check it.
"Fabrice MOUSSET" wrote:
> .
>
I tried by changing as you said but no luck. Still i am getting the same
error. Do i missing something in the sysgen or updates?
"Fabrice MOUSSET" wrote:
> .
>
--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT Eurotech DOT com
My BLOG http://geekswithblogs.net/bruceeitman
Eurotech Inc.
www.Eurotech.com
"Salim" <Sa...@discussions.microsoft.com> wrote in message
news:6AC102CC-A3B2-4600...@microsoft.com...
>> ; R�glage du client SNTP pour forc�e la mise � jour
>> ; automatique de la date et de l'heure
>> [HKEY_LOCAL_MACHINE\Services\Timesvc]
>> "AutoUpdate"=dword:1
>> "ClientOnly"=dword:1
>> "AutoDST"=dword:1
>> "Trustlocalclock"=dword:0
>> "Refresh"=dword:48190800 ; 2 weeks
>> "RecoveryRefresh"=dword:1B7740 ; 30 minutes
>> "Threshold"=dword:5265C00 ; 1 day
>> "Server"="pool.ntp.org"
>>
>>
>> Hope this help
>>
>> Fabrice
>>
>> Le 08/03/2010 11:56, Salim a �crit :
For parameters:
1. Don't set the frequency of sync (Refresh), to less than 5 minutes, as the
server will reject that. The value for 5 minutes is, of course, 5*60*1000
milliseconds.
2. Set Threshold to a large number. If you set it small, the amount of
correction, particularly if your time zone is set wrong, will be too much and
the sync will fail. This shouldn't cause a parameter error, but the sync
will not happen.
3. Set the recovery interval (RecoveryRefresh), to 5 minutes or more, but to
a value less than the refresh interval. If it's greater than the refresh
interval, you'll get an error.
4. For the Server list, you might try double-null terminating the list
something like this:
"Server"=multi_sz:"pool.ntp.org\0\0"
or not using a multi_sz registry type for the data:
"Server"="pool.ntp.org"
I don't have any examples of setting the server in a REG file, but my code
always double-nulls the end of the list. Note that Fabrice's example does
NOT use multi_sz and the server seems to be OK with that.
For IoControl:
The control calls for Sync and Set don't have return data, so you don't need
to pass a return buffer or a pointer for return of bytesReturned.
Paul T.
"Bruce Eitman [eMVP]" wrote:
> >> ; Réglage du client SNTP pour forcée la mise à jour
> .
>
As you said i tried still no luck. Actually network is connected through
GPRS, is any other registry need for GPRS? My GPRS is connected and i am able
to browse.
Paul T.
We have WiFi in the board. I tried with the WiFi. No change in the status. I
tested with the Rebex tool, through that tool i am able to receive the time.
Apart from using IO_CONTROL, is there any other way to test it. As we have
"Update Now" facility in PC.
So, build a DEBUG OS image, set some breakpoints in the SNTP service, run
your program and track down where the service is deciding that there's a
parameter problem. That will point you to the solution, which I'm betting is
a change to the registry settings, despite not seeing any problem with your
settings myself.
Paul T.
Strange, it is working in debug build but it is not working in release
build. What could be the reason? Does it required some delay?
Thanks
"Paul G. Tobey [eMVP]" wrote:
Paul T.
I think i found the issue. I think there is some issue with the default
release timesvc.dll. I just rebuild the TIMESVC2 folder under
Private\servers\ .
Thanks for the help.