File: ...\Samples\Solution\Winapi\Systime.scx
This example illustrates calling the Windows API function GetSystemTime. GetSystemTime fills in a structure of WORD (16-bit unsigned integer) values with system time information.
C Function Declaration and Struct Definition
| В | Copy Code |
|---|---|
VOID GetSystemTime(
LPSYSTEMTIME lpSystemTime // address of system time structure
); | |
This is the struct definition:
| В | Copy Code |
|---|---|
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME; | |
Calling the Function in Visual FoxPro
The Visual FoxPro code passes GetSystemTime, a reference to a character variable, which is filled in with the WORD values.
| В | Copy Code |
|---|---|
* Visual FoxPro Code: cmdSystemTime.Click DECLARE INTEGER GetSystemTime IN win32api STRING @ cBuff=SPACE(40) GetSystemTime(@cBuff) | |
To retrieve the information from the character variable, cBuff, the following code converts 8-bit ASCII characters for year and month in the variable into 16-bit equivalents.
| В | Copy Code |
|---|---|
THIS.Parent.lblYear.Caption = ALLTRIM(STR(ASC(SUBSTR(cBuff,2)) * 256 + ASC(SUBSTR(cBuff,1)))) THIS.Parent.lblMonth.Caption = MONTH_LOC + ALLTRIM(STR(ASC(SUBSTR(cBuff,4)) * 256 + ASC(SUBSTR(cBuff,3)))) | |
js editor
Web development