如何利用WinCC的功能确定电脑时间为夏令时或冬令时?

说明
下面的C脚本确定了您计算机上组态的夏令时/冬令时。

在全局脚本编辑器〉C编辑器〉项目函数 中建立一个名为“SummerWinterFlag”项目函数,再把C脚本拷贝到这个函数中。然后调用这个函数,如通过一个按钮的鼠标单击事件来调用。返回值为相应的夏令时/冬令时值。

注意
本例中的返回值也通过printf()输出。

项目函数

typedef struct _TIME_ZONE_INFORMATION {
LONG Bias;
WCHAR StandardName[ 32 ];
SYSTEMTIME StandardDate;
LONG StandardBias;
WCHAR DaylightName[ 32 ];
SYSTEMTIME DaylightDate;
LONG DaylightBias;
} TIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;

void SommerWinterFlag()
{
#pragma code(“kernel32.dll”)
DWORD GetTimeZoneInformation( LPTIME_ZONE_INFORMATION lpTimeZoneInformation );
#pragma code()

TIME_ZONE_INFORMATION tzi;
DWORD ret;

ret = GetTimeZoneInformation( &tzi );

// printf(“ret = %drn”, ret);

if (ret == 0)
{
printf(“unbekate Zeitrn”);
}
else if (ret == 1)
{
printf(“Standard Zeitrn”);
}
else if (ret == 2)
{
printf(“Sommer Zeitrn”);
}
else { printf(“ungültiger Wert”);
}

}

原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc332457.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2020年11月5日
下一篇 2021年4月12日

相关推荐

发表回复

登录后才能评论