🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13277

Re: Problems with SetFileTime()

#13277
From: Ed Mulroy [TeamB]
Date: Sat, 18 Oct 2003 01:51
54 lines
2837 bytes
Are you working with a file on a FAT32 disk?  If so, it does not maintain
correct access times.  All the non-NTFS disk formats seem to have only
limited time and date information for files.  Some OS's such as Win95 may
have more limitations.

For example here is a screen scrape of a utility reporting the times and
dates for the winhlp32.exe that came with XP on a FAT32 drive.  There is no
way that it had today as the last access time.

  -------------------------
  C:\Projects\s8
  >s8 show -t \winnt\winhlp32.exe
  S Version 8.0 Copyright 1988-2003 Emdata Co
  C:\winnt\winhlp32.exe
    266,752 bytes  Archive
    Write  8-29-02  6:41  Access 10-17-03  0:00  Created  9-13-02 17:29
  1 Files  266,752 Bytes

  C:\Projects\s8
  >

  -------------------------

.  Ed

> nicolasr wrote in message
> news:3f9088b2@newsgroups.borland.com...
>
> I want to change the dates of a file. As described in the
> Windows SDK help I use CreateFile() to get a handle and
> then call SetFileTime().
>
> HANDLE h = CreateFile(fileName,
>                                GENERIC_WRITE,
>                                0,
>                                NULL,
>                                OPEN_EXISTING,
>                                0,
>                                NULL);
>
> SetFileTime(h, &creationTime, &lastAccessTime, &lastWriteTime);
>
> //Sleep(5000);
> CloseHandle(h);
>
> The problem is that the last access time is always reset to
> the current date/time after I changed it. If I delay the call to
> CloseHandle() by 5 sec the last access time is correct for
> 5 sec but after CloseHandle() Windows Explorer seems to
> reset the date.
>
> What's the use of SetFileTime() when I need to open/close
> the file to set the dates and CloseHandle() is considered to
> be an "access", thus again changing the last access time?
Technical Details
Message-ID: <3f909cbf@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f9088b2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,49076709777e4e9f
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-17 19:09:06 PST
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f9088b2@newsgroups.borland.com>
Subject: Re: Problems with SetFileTime()
Date: Fri, 17 Oct 2003 21:51:57 -0400
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <3f909cbf@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066441919 24.74.175.102 (17 Oct 2003 18:51:59 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail