🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Problems with SetFileTime()

#13275
From: nicolasr
Date: Sat, 18 Oct 2003 00:26
31 lines
1847 bytes
Hi,

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?

thanks for any idea,
Nick
Technical Details
Message-ID: <3f9088b2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp.abs.net!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,49076709777e4e9f,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-17 17:36:22 PST
From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Problems with SetFileTime()
Date: Sat, 18 Oct 2003 02:26:24 +0200
Lines: 33
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.1165
NNTP-Posting-Host: 80.133.171.222
Message-ID: <3f9088b2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066436786 80.133.171.222 (17 Oct 2003 17:26:26 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp.abs.net!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail