Jean,

WOW! That's great info and certainly more than I remember.

Thanks!

Malcolm


----- Original message -----
From: "Jean Laeremans" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Date: Fri, 13 Jul 2007 16:15:34 +0200
Subject: Re: Any way to have the OS change the date last modified on a
file?

On 7/13/07, Malcolm Greene <[EMAIL PROTECTED]> wrote:
> Caution: FoxTouch() has some bugs. Unfortunately I can't remember the
> specifics. You may want to search this forum's archives and/or check out
> the UT or Tek-tips for more details.
>
> Malcolm

Indeed.
A+
jml
(from Extended foxtools help by George Tasker

Modifies the date/time stamp of a specified file.

Syntax

lnresult = FoxTouch(lcFilename, lnYear, lnMonth, lnDay,;
  lnHours, lnMinutes, lnSeconds)

lcFilename

A character string representing the fully qualified file name.

lnYear

The 4 digit numeric value of the year.

lnMonth

The numeric month (1 - 12).

lnDay

The day number within the month.

lnHours

The hour number (0 - 23) of the day.

lnMinutes

The minute number of the hour (0 - 59).

lnSeconds

The number of seconds (0 - 59).

Returns

Numeric

Remarks

The function always appears to return 0 even if the file does not
exist. According to the documentation, if no date is passed the
function uses the system date and time. Unfortunately, this is
inaccurate. Calling FoxTouch() in VFP 5.0/6.0 without first providing
it with the desired all parameters results in a data type mismatch
error. If, however, you provide the parameters, any call to FoxTouch()
after the initial one, that does not provide the parameters, will
cause the function to use the previously provided ones.

Further, in 5.0/6.0 the function apparently assumes that the value
being passed is in UTC (Universal Coordinated Time) time, and stamps
the file accordingly. In the Eastern time zone of the United States,
this will cause the file to receive a last modification date/time that
is 4 (under Daylight Savings Time) or 5 hours (under Standard Time)
earlier than the desired value. Naturally, other time zones will
receive different results. There are three possible workarounds for
this problem. One is to retrieve the key
HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\TimeZoneInformation\ActiveTimeBias
from the registry as a string and convert it to the value in minutes.
The second is to retrieve the current bias from
GetTimeZoneInformation(). The second example demonstrates this
technique.

Example

The following example uses FoxTouch() to terminate an executable after
30 days of usage. It increments the seconds to keep track of the
number of days. If 30 days have elapsed since the first usage, the
function returns .T. The function is written for usage under VFP. FPW
users should modify the function due to the absence of the DATETIME()
function. The function, however, is not foolproof, since it can be
overcome by modifying the system date. Further, it relies on the fact
that the seconds are not shown in the Windows 95 Explorer.

FUNCTION ThirtyDays

LPARAMETER pcfile
* pcfile is the fully qualified file name

LOCAL a_dir, lnyear, lnday, lnmonth, lnhour, lnmin, lnsecs,;
  llresult, lnfiles, ldtoday
* Set return value so that if the file is not present
* the program will not run.
llresult = .T.
IF FILE(pcfile)
  = ADIR(a_dir, pcfile)
  lnyear = YEAR(a_dir[1, 3])
  ldtoday = DATETIME()
  IF lnyear = 1980
    * First use, so stamp it with the current
    * date and time with seconds at 0

    lnyear = YEAR(ldtoday)
    lnmonth = MONTH(ldtoday)
    lnday = DAY(ldtoday)
    lnhour = HOUR(ldtoday)
    lnmin = MINUTE(ldtoday)
    lnsec = 0
  ELSE
    * Otherwise, modify the seconds
    * if necessary
    lnmonth = MONTH(a_dir[1, 3])
    lnday = DAY(a_dir[1, 3])
    lnhour = VAL(LEFT(a_dir[1, 4], 2))
    lnmin = VAL(SUBSTR(a_dir[1, 4], 3, 2))
    lnsec = VAL(RIGHT(a_dir[1, 4], 2))
    IF DATE() > a_dir[1, 3] + lnsecs
      lnsec = lnsec + 1
    ENDIF

    llresult = (lnsec = 30)
  ENDIF
  = FoxTouch(pcfile, lnyear, lnmonth, lnday, lnhour, lnmin, lnsec)
ENDIF
RETURN llresult

The following example demonstrates how to call
GetTimeZoneInformation() to retrieve the current bias and overcome the
bug mentioned above. This applies to the 6.0 version of the library.
Early or later releases should be tested prior to use.

FUNCTION FoxStamp
  Adjusts for the FoxTouch() UTC bug

  LPARAMETER tfilename, ttDateTime

  The file to stamp

A date/time to stamp it with

DECLARE INTEGER GetTimeZoneInformation IN Win32API;
  STRING @lpTimeZoneInformation
LOCAL lctimezone, lnbias, ltdatetime
lctimezone = REPLICATE(CHR(0), 172)
= GetTimeZoneInformation(@lctimezone)
* Convert to and integer number of seconds to add or subtract
lnbias = StringToInteger(LEFT(lctimezone, 4, .T.) * 60
ltdatetime = ttDateTime + lnbias
RETURN FoxTouch(tfilename, YEAR(ltdatetime), MONTH(ltdatetime),;
  DAY(ltdatetime), HOUR(ltdatetime), MINUTE(ltdatetime),;

  SEC(ltdatetime))

FUNCTION StringToInteger

  LPARAMETER pcstring, plsigned

LOCAL lnresult, lnlast, lni, llsigned,;
  lnmsb, lnmax
lnresult = 0
lnlast = LEN(pcstring)
* Return Signed Integer?
IF PCOUNT() = 2
  llsigned = plsigned
ELSE
  llsigned = .F.
ENDIF
FOR lni = 1 TO lnlast
  lnresult = lnresult + ASC(SUBSTR(pcstring, lni, 1)) * (256 ^ (lni -
  1))
NEXT
IF llsigned
  lnmsb = (lnlast * 8) - 1
  IF BITTEST(lnresult, lnmsb)
    lnmax = (2 ^ (lnmsb + 1))

    lnresult = lnresult - lnmax
  ENDIF
ENDIF
RETURN lnresult


[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to