GrabBag/VrUtils/Inc/VrNTPUtils.h
2025-06-08 12:48:04 +08:00

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
/// ³õʼ»¯NTPClient
bool InitNTPClient(char* sIP = nullptr, int nPort = 123);
/// Í˳öNTPClient
bool ExitNTPClient();
///»ñȡʱ¼ä
bool GetSystemTime(SYSTEMTIME& newtime);
private:
bool _UpdateDate();
private:
char m_sIP[16];
bool m_bValidIP;
int m_nPort;
};