Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using SetSystemDate
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00938454
Message ID:
00938455
Views:
10
>How to use this function to change System's date?

Several years ago we had a program that used SetLocalTime, we barely used though, and the code should be similar to the SetSystemTime, but you need to convert the time to UTC prior to calling it, this was our (awfull) function:
* This function sets the date and time of the workstation to the value passed as parameter

* Return Type: 'L' (Logical, .t. if succeed)

lparameters ltDateTime
local cTime, cYear, cMonth, cDayOfWeek, cDay, cHours, cMinutes, cSeconds, cMilliSeconds

if vartype(ltDateTime)#'T'
	return .f.
endif

declare SetLocalTime in kernel32 string @ cTime

cTime=replicate(' ', 16)

cYear=n2ws(year(ltDateTime))
cMonth=n2ws(month(ltDateTime))
cDayOfWeek=n2ws(dow(ltDateTime))
cDay=n2ws(day(ltDateTime))
cHours=n2ws(hour(ltDateTime))
cMinutes=n2ws(minute(ltDateTime))
cSeconds=n2ws(sec(ltDateTime))
cMilliSeconds='  '
cTime=cYear+cMonth+cDayOfWeek+cDay+cHours+cMinutes+cSeconds+cMilliSeconds
return SetLocalTime(@cTime)

*------------------------------------------------------------------------------
* function n2ws
* 
* Converts a number into a 2 chars string (Number to Word String)

function n2ws(nNumber)

return chr(nNumber%256)+chr(nNumber/256)
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform