Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use SetSystemTime and SetLocalTime ?
Message
From
14/05/1998 10:10:24
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00099392
Message ID:
00099408
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


Thank you, It works great and it saved me a substantial amount of time, trying to figure this out.
Joel W. Willsey
Previous
Reply
Map
View

Click here to load this message in the networking platform