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

Click here to load this message in the networking platform