51 lines
606 B
C
51 lines
606 B
C
|
|
#pragma once
|
|||
|
|
|
|||
|
|
#ifdef _WIN32
|
|||
|
|
#include <WS2tcpip.h>
|
|||
|
|
#include <WinSock2.h>
|
|||
|
|
#endif // _WIN32
|
|||
|
|
|
|||
|
|
|
|||
|
|
class CrNTPUtils
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
CrNTPUtils();
|
|||
|
|
~CrNTPUtils();
|
|||
|
|
|
|||
|
|
|
|||
|
|
#ifndef _WIN32
|
|||
|
|
public:
|
|||
|
|
struct SYSTEMTIME
|
|||
|
|
{
|
|||
|
|
int wYear;
|
|||
|
|
int wMonth;
|
|||
|
|
int wDayOfWeek;
|
|||
|
|
int wDay;
|
|||
|
|
int wHour;
|
|||
|
|
int wMinute;
|
|||
|
|
int wSecond;
|
|||
|
|
int wMilliseconds;
|
|||
|
|
};
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <20><>ʼ<EFBFBD><CABC>NTPClient
|
|||
|
|
bool InitNTPClient(char* sIP = nullptr, int nPort = 123);
|
|||
|
|
|
|||
|
|
/// <20>˳<EFBFBD>NTPClient
|
|||
|
|
bool ExitNTPClient();
|
|||
|
|
|
|||
|
|
///<2F><>ȡʱ<C8A1><CAB1>
|
|||
|
|
bool GetSystemTime(SYSTEMTIME& newtime);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
bool _UpdateDate();
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
char m_sIP[16];
|
|||
|
|
bool m_bValidIP;
|
|||
|
|
int m_nPort;
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|