Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A way to change system date/time programatically from VF
Message
De
14/09/1998 06:31:18
 
 
À
14/09/1998 03:11:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00135525
Message ID:
00136066
Vues:
19
>George, Vlad
>Thanks a lot to both of you, but i've checked this code and doesn't works in my system. I have Windows 98. What am i missing? Thanks again
>
>
>lcsystime = "9801 0110201500"

You have to build the binary structure required by SetLocalTime into the string, not pass an ASCII representation: FWIW, the structure looks like:
    WORD wYear
    WORD wMonth
    WORD wDayOfWeek
    WORD wDay
    WORD wHour
    WORD wMinute
    WORD wSecond
   WORD wMilliseconds
A WORD is an unsigned 16 bit binary number ordered . A simple function that convert an integer to a WORD string would be:
FUNCTION NumToWord
LPARAMETER nNumBerToConvert
RETURN CHR(MOD(nNumberToConvert,256)) + CHR(INT(nNumberToConvert/256))
You could then make your SYSTEM_TIME structure:


lcSystime> = NumToWord(1998) + ;
NumToWord(1) + ;
NumToWord(DOW({^ 1998 01 01})) + ;
NumToWord(1) + ;
NumToWord(0) + ;
NumToWord(0) + ;
NumToWord(0) + ;
NumToWord(1)

which would be midnight + 1 millisecond, January 1 1998.
>
>DECLARE SHORT SetLocalTime IN Win32API;
> STRING @lpst
>? SetLocalTime(@lcsystime) && returns 0
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform