Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use SetSystemTime and SetLocalTime ?
Message
From
14/05/1998 09:25:15
 
 
To
14/05/1998 09:22:32
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00099392
Message ID:
00099394
Views:
28
>Does anyone know how to use these, I need to be able to set system time through an VFP application .

Hi Joel,

This is the code I wrote to use the SetLocalTime - sorry about the formatting - I'm not a HTML user!

FUNCTION SetDateTime
PARAMETERS tlDateTime
LOCAL lcSetValue, lnStatus

*-- Use the Win API function
*-- When used on NT an extra Privilege has to be set!!

DECLARE INTEGER SetLocalTime IN win32api STRING @

*-- Build up a structure for the date time
*-- Year, Month, Day Of Week (Monday = 1), Day, Hour, Minute - ignore second and millisecond
lcSetValue = CHR( MOD( YEAR( tlDateTime), 256)) + CHR( INT( YEAR( tlDateTime) / 256)) + ;
CHR( MONTH( tlDateTime)) + CHR( 0) + ;
CHR( DOW( tlDateTime, 2)) + CHR( 0) + ;
CHR( DAY( tlDateTime)) + CHR( 0) + ;
CHR( HOUR( tlDateTime)) + CHR( 0) + ;
CHR( MINUTE( tlDateTime)) + CHR( 0) + ;
CHR( VAL( RIGHT( TTOC( tlDateTime), 2))) + CHR( 0) + ;
CHR( 0) + CHR( 0) + CHR(0)

lnStatus = SetLocalTime( lcSetValue)
IF lnStatus = 0
lnStatus = _ValidError
DebugMsg( 'Problem setting the time')
ELSE
lnStatus = 0
ENDIF

RETURN lnStatus

HTH
regards

Ian
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform