Announcement

Collapse
No announcement yet.

FileDateTime Stamp?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FileDateTime Stamp?

    Help me please:
    - as FileDate and FileTime Stamps can get fast? (e.g. in Variable)
    (c:\probe.bin ... 31.01.2000 10:16 <== Europa Format)
    ~~~~~~~~~~ ~~~~~
    |-----|------ ???
    - as that can modify?

    Thanks.


  • #2
    check out the getfiletime() and setfiletime() api's... they work to read/set the date and the time of files.

    there is at least one postings that may help you:


    -------------
    lance
    powerbasic support
    mailto:[email protected][email protected]</a>
    Lance
    mailto:[email protected]

    Comment


    • #3
      I wrote a freeware utility (you can download it from http://www.direct-print.com) that is using the following code:

      SUB FileDate(BYVAL task AS LONG, iFile AS STRING, iYear AS LONG, iMonth AS LONG, iDay AS LONG, iHour AS LONG, iMinute AS LONG, iSecond AS LONG)

      'Note: sets date if task <> 0
      ' returns date when task = 0
      LOCAL lpCreationTime AS FILETIME
      LOCAL lpLastAccessTime AS FILETIME
      LOCAL lpLastWriteTime AS FILETIME
      LOCAL sysT AS SYSTEMTIME
      LOCAL locT AS FILETIME
      LOCAL lpFileName AS ASCIIZ * 260
      LOCAL lpReOpenBuff AS OFSTRUCT
      LOCAL lpFatDate AS WORD
      LOCAL lpFatTime AS WORD

      LOCAL hFile AS LONG

      IF LEN(iFile) = 0 THEN EXIT SUB

      lpFileName = iFile
      hFile = OpenFile(lpFileName, lpReOpenBuff, %OF_READWRITE)
      CALL GetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime)

      CALL FileTimeToLocalFileTime(lpLastWriteTime, locT)
      CALL FileTimeToSystemTime(locT, sysT)
      IF task = 0 THEN
      'the return values need to be set
      iYear = sysT.wYear
      iMonth = sysT.wMonth
      iDay = sysT.wDay
      iHour = sysT.wHour
      iMinute = sysT.wMinute
      iSecond = sysT.wSecond
      ELSE
      'set new time as was passed
      sysT.wYear = iYear
      sysT.wMonth = iMonth
      sysT.wDay = iDay
      sysT.wHour = iHour
      sysT.wMinute = iMinute
      sysT.wSecond = iSecond
      CALL SystemTimeToFileTime(sysT, locT)
      CALL LocalFileTimeToFileTime(locT, lpLastWriteTime)
      CALL SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime)
      END IF
      CALL CloseHandle(hFile)
      END SUB


      Comment

      Working...
      X