官网提供了例程,官网真是个宝库。基本ADS的操作都里面有例程了,但是可能会稍微分散一点,不过多看几遍,也就慢慢整理你所需要的东西出来了。
#include <Windows.h>
#include <conio.h>
#include <winbase.h>
#include <TcAdsDef.h>
#include <TcAdsAPI.h>
void myPAdsNotificationFuncEx(AmsAddr* pAddr,
AdsNotificationHeader* pNotification,
unsigned long hUser
)
{
SYSTEMTIME SystemTime, LocalTime;
FILETIME FileTime;
LARGE_INTEGER LargeInteger;
TIME_ZONE_INFORMATION TimeZoneInformation;
// Convert the timestamp into SYSTEMTIME
LargeInteger.QuadPart = pNotification->nTimeStamp;
FileTime.dwLowDateTime = (DWORD)LargeInteger.LowPart;
FileTime.dwHighDateTime = (DWORD)LargeInteger.HighPart;
FileTimeToSystemTime(&FileTime, &SystemTime);
// Convert the time value Zeit to local time
GetTimeZoneInformation(&TimeZoneInformation);
SystemTimeToTzSpecificLocalTime(&TimeZoneInformation, &SystemTime, &LocalTime);
// Print out the timestamp
qDebug() << LocalTime.wHour << ":"
<< LocalTime.wMinute << ":"
<< LocalTime.wSecond << '.'
<< LocalTime.wMilliseconds;
//这样子不行,貌似Qt不支持这种timeStamp
//qDebug() << QDateTime::fromTime_t(pNotification->nTimeStamp);
}