Suppose for the purposes of a test it is necessary to have a time stamp that will be more precise than the nearest second. Silk Performers GetCurrentTime function only returns a value in seconds but the windows kernel32.dll has a GetSystemTime function that returns values in milliseconds. This GetSystemTime function returns values is a structure Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type The following code sample shows how to get values from the callback function in the kernel32.dll / /////////////////////////////////////////////////////////////////// use "Kernel.bdh" dll "kernel32.dll" //uses kernel32 "GetSystemTime" //kernel32 function called function GetSystemTime(inout string); dcluser user VUser transactions TSystemTime : 2; dcltrans transaction TSystemTime var // pSystemTime : string; // nYear : number; nMonth : number; nDoW : number; nDay : number; nHour : number; nMin : number; nSec : number; nMSec : number; // begin // GetSystemTime(pSystemTime); // nYear := GetShort(pSystemTime,1); //assign the GetSystemTime structure to variables nMonth := GetShort(pSystemTime,3); nDoW := GetShort(pSystemTime,5); nDay := GetShort(pSystemTime,7); nHour := GetShort(pSystemTime,9); nMin := GetShort(pSystemTime,11); nSec := GetShort(pSystemTime,13); nMSec := GetShort(pSystemTime,15); // writeln("Year : " +string(nYear)); //writes out all dates and times writeln("Month : " +string(nMonth)); writeln("Day of Week : " +string(nDoW)); writeln("Day : " +string(nDay)); writeln("Hour : " +string(nHour)); writeln("Minutes : " +string(nMin)); writeln("Seconds : " +string(nSec)); writeln("MilliSeconds : " +string(nMSec)); writeln("---------------------------------------------------"); // end TSystemTime; //end bdf code /////////////////////// // SAMPLE OUTPUT /////////////////////// Year : 2002 Month : 5 Day of Week : 1 Day : 20 Hour : 15 Minutes : 26 Seconds : 13 MilliSeconds : 806 -------------------------------- Year : 2002 Month : 5 Day of Week : 1 Day : 20 Hour : 15 Minutes : 26 Seconds : 13 MilliSeconds : 816 --------------------------------- Old KB# 19439
↧