Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change system date programatically
Message
From
04/01/2005 09:39:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/01/2005 09:06:58
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00974058
Message ID:
00974069
Views:
35
This message has been marked as the solution to the initial question of the thread.
>Dear Experts
>
>To change system date programatically I use following method
>
>lcCmd = GETENV("ComSpec") + [ /C ]
>lcCmd = lcCmd + [ DATE 04-01-2005"
>loShell = CREATEOBJECT("wscript.shell")
>= loShell.Run(lcCmd,1,.t.)
>
>This works fine but I want to change system date with date given in a textbox.
>
>To do this there is a date type textbox containing value 04-10-1975
>And there is a command button having following code
>
>lcCmd = GETENV("ComSpec") + [ /C ]
>DATE1=thisform.text2.Value
>lcCmd = lcCmd + [ date ] + DATE1
>loShell = CREATEOBJECT("wscript.shell")
>= loShell.Run(lcCmd,1,.t.)
>
>But it does not work and shows error message, Operator/Operant type mismatch.
>
>Please help
ltNow = Datetime()
? 'Now',Datetime()
SetSystemDate({^2002/1/3})
? 'Set to',Datetime()
SetSystemDate(m.ltNow)
? 'Set back to',Datetime()


Function SetSystemDate
  Lparameters tdDate
  Declare Integer SetLocalTime In win32api String @ lpTime
  Declare Integer GetLocalTime In win32api String @ lpTime
  Local lpCurrent, lcNewTime
  lpCurrent = Space(40)
  GetLocalTime(@lpCurrent) && save current

  lcNewTime = Num2Word(Year(m.tdDate))+;
    Num2Word(Month(m.tdDate))+;
    Num2Word(Dow(m.tdDate))+;
    Num2Word(Day(m.tdDate))+;
    Substr(m.lpCurrent,9)

  SetLocalTime(@lcNewTime) && Warning: Intentionally called twice
  SetLocalTime(@lcNewTime)
EndFunc

Function Num2Word
  Lparameters tnDecimal
  Return Chr(m.tnDecimal%256)+Chr(Int(m.tnDecimal/256))
EndFunc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform