在WINCC中显示系统时间,建一个全局动作
#include "apdefap.h"
int gscAction( void )
{
#pragma code("kernel32.dll");
void GetLocalTime(LPSYSTEMTIME lpSystemTime);
#pragma code();
SYSTEMTIME time;
GetLocalTime(&time);
SetTagWord("year",time.wYear );
SetTagWord("month",time.wMonth );
SetTagWord("week",time.wDayOfWeek );
SetTagWord("day",time.wDay );
SetTagWord("hour",time.wHour );
SetTagWord("minute",time.wMinute );
SetTagWord("second",time.wSecond );
return 0;
}
然后建“year"等7个内部变量
再建几个静态文本,比如说年、月等,在年的字体属性中选择动态-内部变量是”year",可是始终读不到系统的年份,请各楼主帮忙看看,
是否全局脚本有问题,这个例子是原来已成功运行的,我现在是新的项目重做的。
这是我运行正常的代码,你仔细核对以下
#pragma code("kernel32.dll")
void GetLocalTime(LPSYSTEMTIME lpSystemTime);
#pragma code()
SYSTEMTIME time;
GetLocalTime(&time);
SetTagWord("year",time.wYear );
SetTagWord("month",time.wMonth );
SetTagWord("week",time.wDayOfWeek );
SetTagWord("day",time.wDay );
SetTagWord("hour",time.wHour );
SetTagWord("minute",time.wMinute );
SetTagWord("second",time.wSecond );
return 0;