k = datetime() cDateTime = Date2Str(m.k) my_custom_dll_function(m.cDateTime) Function Date2Str Lparameters ttValue Local lcDay,lcTime,ix,lcDateTimeStr lcDay = Transform(Val(Sys(11,m.ttValue)),'@0') lcTime = Transform((m.ttValue - Dtot(Ttod(m.ttValue))) * 1000,'@0') lcDateTimeStr = '' For m.ix=4 To 1 Step -1 lcDateTimeStr = m.lcDateTimeStr + Substr(m.lcDay,m.ix*2+1,2) Endfor For m.ix=4 To 1 Step -1 lcDateTimeStr = m.lcDateTimeStr + Substr(m.lcTime,m.ix*2+1,2) Endfor Return m.lcDateTimeStrIf you've used Foxpro API (location is different depending on version, generally home()+'samples\API') it has a Value structure to pass parameters. In that Value stucture ev_type is 'T' and ev_real is a double precision folting point number representing a datetime (time part is fraction). But I think you'd be fine with the above code. DLL might be expecting datetime in more common C datetime formats like a SystemTime structure (where year, month, day ... millisecond are defined as WORD). For this type you might do the conversion:
lcSysTime = N2S(Year(m.ttDateTime), 2) + ; N2S(Month(m.ttDateTime), 2) +; N2S(Dow(m.ttDateTime), 2) + ; N2S(Day(m.ttDateTime), 2) +; N2S(Hour(m.ttDateTime), 2) +; N2S(Minute(m.ttDateTime), 2) +; N2S(Sec(m.ttDateTime), 2) + ; N2S(m.tnMillisecs, 2) My_C_Function(m.lcSysTime) Function N2S Lparameters tnValue, tnSize Local lcStr, ix lcStr = "" For ix=1 To m.tnSize lcStr = m.lcStr + Chr(m.tnValue % 256) tnValue = Int(m.tnValue/256) Endfor Return m.lcStrPS: If you've doubts try the second one and in C DLL create a function that'd accept SYSTEMTIME structure. Above code would populate the members.
typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME;MFC Ctime class has a constructor accepting SYSTEMTIME.
typedef struct _FOXPRODATETIME { DWORD date; DWORD nanoseconds; } _FOXPRODATETIME; public void my_custom_dll_function( CONST _FOXPRODATETIME *dt ) { // After foxpro calls this function /* k = datetime() cDateTime = Date2Str(m.k) my_custom_dll_function(m.cDateTime) */ // dt.date member - has the date as a Julian day number // dt.nanoseconds - member has time as seconds*1000 // from midnight }Cetin