Partager via


SNTP Service Configuration Code Sample (Windows Embedded CE 6.0)

1/6/2010

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