Share via


SNTP Service Configuration Code Sample

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

The following code example shows how to configure the SNTP service for Windows Embedded CE using Services.exe:

int WINAPI
WinMain(HINSTANCE hInstance,
   HINSTANCE hPrevInstance,
#ifdef UNDER_NT
   LPSTR   lpCmdLine,
#else
LPWSTR   lpCmdLine,
#endif
int   nCmdShow)
{
HANDLE hFile=CreateFile(L"NTP0:",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(INVALID_HANDLE_VALUE==hFile)
return 0;

WCHAR szControlString[]=L"sync";
DWORD dwLenIn=sizeof(szControlString);
DWORD dwBytesReturned;

DeviceIoControl(hFile, IOCTL_SERVICE_CONTROL, szControlString, dwLenIn, NULL, 0, &dwBytesReturned, NULL);
return 0;
     }

See Also

Concepts

Configuring the SNTP Service