Article View: borland.public.cppbuilder.nativeapi
Article #14177Re: FileTimeToSystemTime
From: Ed Mulroy [TeamB]
Date: Wed, 03 Sep 2003 11:31
Date: Wed, 03 Sep 2003 11:31
48 lines
2929 bytes
2929 bytes
There are a couple of things worth mentioning about that code. The file times may appear incorrect because they are GMT. To handle that, call FileTimeToLocalFileTime before calling FileTimeToSystemTime. MS introduced Hungarian notation because at the time type checking in their compiler was weak or non-existent. The prefix "lp" was used as in "long pointer" (back then pointers came in near or far, often called short or long). The name you use for an instance of the SYSTEMTIME structure is lpSystemTime, a name which indicates a pointer to such a structure but the variable is not a pointer. If you must use Hungarian notation, please do not have it indicate a wrong type. . Ed > Larry Johnson wrote in message > news:3f55cc76@newsgroups.borland.com > > I am trying to get a file time and look at it using > FileTimeToSystemTime. This requires three APIs, > CreateFile, GetFileTime and FileTimeToSystemTime. > I am using the code below to do this. The file TimeTest.txt > is a simple text file in the same folder as the exe. The > numbers in the lpSystemTime structure of the > FileTimeToSystemTime API are junk numbers and I am > not sure why. Do you see any problems with my code. > > ============================================ > #include <windows.h> > #include <winbase.h> > > bool result; > FILETIME ftCreate, ftAccess, ftWrite; > HANDLE hFile; > SYSTEMTIME lpSystemTime; > LPCTSTR FileName; > > FileName = "TimeTest.txt"; > > hFile = CreateFile( FileName, > GENERIC_READ | GENERIC_WRITE, > 0, NULL, OPEN_ALWAYS, > FILE_ATTRIBUTE_NORMAL, NULL ); > > result= GetFileTime( hFile, &ftCreate, &ftAccess, &ftWrite ); > > result= FileTimeToSystemTime( &ftWrite, &lpSystemTime ); > ============================================
Technical Details
Message-ID:
<3f55d136$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f55cc76@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7905adfcdd54cb3c X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-03 04:45:48 PST From: "Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f55cc76@newsgroups.borland.com> Subject: Re: FileTimeToSystemTime Date: Wed, 3 Sep 2003 07:31:58 -0400 Lines: 50 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: <3f55d136$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1062588726 24.74.175.102 (3 Sep 2003 04:32:06 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail