GrabBag/VrUtils/Inc/VrNTPUtils.h

51 lines
656 B
C
Raw Permalink Normal View History

2025-07-23 01:35:14 +08:00
#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;
};