官网提供了例程,官网真是个宝库。基本ADS的操作都里面有例程了,但是可能会稍微分散一点,不过多看几遍,也就慢慢整理你所需要的东西出来了。
https://infosys.beckhoff.com/index_en.htm
1 #include <Windows.h>
2 #include <conio.h>
3 #include <winbase.h>
4
5 #include <TcAdsDef.h>
6 #include <TcAdsAPI.h>
7
8 void myPAdsNotificationFuncEx(AmsAddr* pAddr,
9 AdsNotificationHeader* pNotification,
10 unsigned long hUser
11 )
12 {
13 SYSTEMTIME SystemTime, LocalTime;
14 FILETIME FileTime;
15 LARGE_INTEGER LargeInteger;
16 TIME_ZONE_INFORMATION TimeZoneInformation;
17
18 // Convert the timestamp into SYSTEMTIME
19 LargeInteger.QuadPart = pNotification->nTimeStamp;
20 FileTime.dwLowDateTime = (DWORD)LargeInteger.LowPart;
21 FileTime.dwHighDateTime = (DWORD)LargeInteger.HighPart;
22 FileTimeToSystemTime(&FileTime, &SystemTime);
23
24 // Convert the time value Zeit to local time
25 GetTimeZoneInformation(&TimeZoneInformation);
26 SystemTimeToTzSpecificLocalTime(&TimeZoneInformation, &SystemTime, &LocalTime);
27
28 // Print out the timestamp
29 qDebug() << LocalTime.wHour << ":"
30 << LocalTime.wMinute << ":"
31 << LocalTime.wSecond << '.'
32 << LocalTime.wMilliseconds;
33
34 //这样子不行,貌似Qt不支持这种timeStamp
35 //qDebug() << QDateTime::fromTime_t(pNotification->nTimeStamp);
36 }
分类:
Qt
, 倍福(Beckhoff)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
2022-08-04 Qt 生成dump文件及windbg调试(进阶版)
2022-08-04 Windows下的Qt编译器 - MinGW和MSVC的区别
2022-08-04 Qt MSVC与MinGW的区别
2022-08-04 Qt 建立带有子项目的项目,以及子项目之间的调用
2021-08-04 使用C#调用C++类库
2021-08-04 C# IntPtr类型
2021-08-04 C# 调用C++ dll string类型返回