一杯清酒邀明月
天下本无事,庸人扰之而烦耳。
posts - 3121,comments - 209,views - 578万

官网提供了例程,官网真是个宝库。基本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 }
复制代码

 

posted on   一杯清酒邀明月  阅读(170)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全网最简单!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类型返回
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示