Kernel32.dll - GetSystemTime()

Blitz3D Forums/Blitz3D Userlibs/Kernel32.dll - GetSystemTime()

_PJ_(Posted 2010) [#1]
Does anyone know how to use this?

from the listed decls in these forums, the format is:

Kernel32_GetSystemTime (lpSystemTime*) : "GetSystemTime"

On the Microsoft website, here

http://msdn.microsoft.com/en-us/library/ms724390(VS.85).aspx

it mentions that "lpSystemTime" is the pointer to a struct

How can this value be enumerated in Blitz?
Presumably it would involve creating a bank in which to store the output, but how large should it be? How do I then know how to reads back the contents correctly?

Any help at all will be greatly appreciated :)


Charrua(Posted 2010) [#2]
reading the link you posted the struct is:

typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;

blitz didn't have 2 byte variables (Word ones) but, you can define a bank of 8 * 2 = 16 bytes and pass it then read in pairs taking into account that a Word is stored Low byte first, High byte second, for example to get the month wich will be at offsets 2,3 you have to read byte 2 and add the byte 3 multiplied by 256 (Word value = HighByte * 256 + LowByte)

hope that help

Juan


Charrua(Posted 2010) [#3]
ok, blitz basic way:

Local SystemTime=CreateBank(16)

api_GetSystemTime(SystemTime)

For i=0 To 7

	Print "Word "+ i + " : " +Int( PeekByte(SystemTime,i*2) + PeekByte(SystemTime,i*2+1)*256)

Next

WaitKey()

End


clearer?

Juan


Charrua(Posted 2010) [#4]
if you prefere to use Blitz types:

;second inplementation, create a type with 16 bytes : 4 Ints = 16 bytes
;each Int stores 2 Words and the Stored Words are, once again LowWord first, HighWord second
Type tSystemTime

	Field YearMonth
	Field DayOfWeekDayOfMonth
	Field HourMin
	Field SecsMillisecs

End Type

SysTime.tSystemTime = New tSystemTime

api_GetSystemTime(SysTime)

Print "Year : " + Int(SysTime\YearMonth And $FFFF)
Print "Month: " + SysTime\YearMonth Shr 16

Print "DayOfWeek : " + Int(SysTime\DayOfWeekDayOfMonth And $FFFF)
Print "DayOfMonth: " + SysTime\DayOfWeekDayOfMonth Shr 16

Print "Hour : " + Int(SysTime\HourMin And $FFFF)
Print "Min  : " + SysTime\HourMin Shr 16

Print "Sec  : " + Int(SysTime\SecsMillisecs And $FFFF)
Print "Milli: " + SysTime\SecsMillisecs Shr 16


WaitKey()

End


Juan


_PJ_(Posted 2010) [#5]
Thanks so much, Charrua!
I'm okay with the Byte structure, but thank you for spending time to show it in simpler formats too!
:)