インターネットから日付/時刻を取得する例を誰でも挙げることができますが、これまでのところ NetRemoteTOD 関数を使用して情報を見つけただけです。
しかし、ポイントは、サーバー名は何ですか、それを使用する方法がわからないということです。関数で以下のコードを試しましたが、実行時エラーが発生します。
感謝する
LPTIME_OF_DAY_INFO pBuf = NULL;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
int CurrentYear ;
int CurrentMonth ;
int CurrentDay ;
int CurrentHour;
int CurrentMin;
pszServerName = (LPTSTR) "time.windows.com";
//
// Call the NetRemoteTOD function.
//
nStatus = NetRemoteTOD((LPCWSTR) pszServerName,(LPBYTE *)&pBuf);
//
// If the function succeeds, display the current date and time.
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
CurrentYear = pBuf->tod_year;
CurrentMonth =pBuf->tod_month;
CurrentDay = pBuf->tod_day;
CurrentHour=pBuf->tod_hours;
CurrentMin=pBuf->tod_mins;
}
}
//
// Otherwise, display a system error.
else
{
m_SharesEdit[9].SetWindowText("No time");
}
//
// Free the allocated buffer.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
if( CTime(CurrentYear,CurrentMonth,CurrentDay,CurrentHour,CurrentMin,0) >= CTime(2013,11,25,9,00,00) )
return true;
else
return false;