Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use SetSystemTime and SetLocalTime ?
Message
De
14/05/1998 10:10:24
 
 
À
14/05/1998 09:25:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00099392
Message ID:
00099408
Vues:
29
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform