回复:WinCC中如何调取电脑系统时间?
显示时间的C动作
#include "apdefap.h"
char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
time_t timer;
struct tm *ptm;
char *p;
time(&timer);
ptm=localtime(&timer);
p=SysMalloc(9);
sprintf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min,ptm->tm_sec);
return(p);
}
显示月的C动作
#include "apdefap.h"
char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#pragma code("kernel32.dll");
VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
#pragma code()
SYSTEMTIME sysTime;
char szTime[6] = " ";
GetLocalTime(&sysTime);
sprintf (szTime,"%02d",sysTime.wMonth);
return szTime;
}
日的C动作
#include "apdefap.h"
char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#pragma code("kernel32.dll");
VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
#pragma code()
SYSTEMTIME sysTime;
char szTime[6] = " ";
GetLocalTime(&sysTime);
sprintf (szTime,"%02d",sysTime.wDay);
return szTime;
}
年的C动作
#include "apdefap.h"
char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#pragma code("kernel32.dll");
VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
#pragma code()
SYSTEMTIME sysTime;
char szTime[6] = " ";
GetLocalTime(&sysTime);
sprintf (szTime,"%02d",sysTime.wYear);
return szTime;
}
|