Article View: borland.public.cppbuilder.nativeapi
Article #866Re: Cannot retrieve file date
From: Ed Mulroy [TeamB]
Date: Wed, 02 Jan 2008 22:05
Date: Wed, 02 Jan 2008 22:05
69 lines
2834 bytes
2834 bytes
-----------------------------
#include <cstdio>
#include <io.h>
using namespace std;
HANDLE STDCALL WindowsHandleFromFILEHandle(FILE *fp)
{
return (HANDLE) _get_osfhandle(fileno(fp));
}
...
in some function
_FILETIME f1 = { 0 };
FILE*han1=fopen("J:\\Projects\\test1.h","r");
if (han1 != NULL) // if file has successfully opened
{
BOOL res;
res=GetFileTime(WindowsHandleFromFILE(han1), &f1,NULL,NULL);
fclose(han1);
han1 = NULL;
if (res == 0) // if error in GetFileTime
memset(&f1, 0, sizeof(f1))l
}
-----------------------------
. Ed
> Jos� wrote in message
> news:hfonn3l8o175ht0j11i9d4q5msanpr6apt@4ax.com...
> What went wrong?
>
> _FILETIME f1;
> FILE*han1=fopen("J:\\Projects\\test1.h","r");
> res=GetFileTime(han1, &f1,NULL,NULL);
>
> The file exists, han1 is not zero and the file can be read. But
> GetFileTime returns an error.
>
> I tried to find what went wrong. The help file tells me to:
>
> LPVOID lpMsgBuf;
>
> But that causes a compilation error, ("cannot convert void * to const
> char *) so I declared:
>
> char* lpMsgBuf;
>
> and it goes on:
>
> FormatMessage(
> FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
> NULL, GetLastError(),
> MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
> (LPTSTR) &lpMsgBuf, 0, NULL);
> MessageBox( NULL, lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION);
> LocalFree( lpMsgBuf );
>
> The error message is "De ingang is ongeldig". If I set the language to
> English, no message is returned. Translated into English, it would be
> "The entry is invalid".
>
> Well, that's good to know: the entry is invalid! But what is the
> entry? And why is it invalid?
> --
Technical Details
Message-ID:
<477c0a92$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<hfonn3l8o175ht0j11i9d4q5msanpr6apt@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4011bf1b28cc5925 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.nativeapi References: <hfonn3l8o175ht0j11i9d4q5msanpr6apt@4ax.com> Subject: Re: Cannot retrieve file date Date: Wed, 2 Jan 2008 17:05:00 -0500 Lines: 71 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 71.77.53.190 Message-ID: <477c0a92$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1199311506 71.77.53.190 (2 Jan 2008 14:05:06 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail