Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using GetFileTime without having to CreateFile first

Posted on 1998-11-17
4
Medium Priority
?
777 Views
Last Modified: 2013-12-03
I am making extensive use of GetFileTime but have to use CreateFile to get the file handle.  Am I right in thinking this will slow things down because the file is being opened every time ?  Is there a waya round this that may speed things up ?
0
Comment
Question by:ssherlock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
trillo earned 300 total points
ID: 1416150
Yes, I think you're right, you may be loosing a lot of time. Try with the following function:

BOOL GetFileAttributesEx (
   LPCTSTR lpFileName,
   GET_FILEEX_INFO_LEVELS fInfoLevelId,
   LPVOID lpFileInformation );

pFileName = Pointer to a null-terminated string that specifies a file or directory.
fInfoLevelId = Enumeration type value that specifies the set of attribute information to obtain. (GetFileExInfoStandard)
lpFileInformation = Pointer to a buffer that receives the attribute information. (WIN32_FILE_ATTRIBUTE_DATA)


typedef struct _WIN32_FILE_ATTRIBUTE_DATA{  
    DWORD      dwFileAttributes;
    FILETIME   ftCreationTime;
    FILETIME   ftLastAccessTime;
    FILETIME   ftLastWriteTime;
    DWORD      nFileSizeHigh;
    DWORD      nFileSizeLow;
}

Actually I took this from the SDK help files (if you don't have the, just tell me and I'll send you all you need about this function).

trillo
0
 

Author Comment

by:ssherlock
ID: 1416151
Thanks, I don't have MSDN installed here due to disk space.  Could you give a small example ?

Cheers, Simon.
0
 
LVL 2

Expert Comment

by:trillo
ID: 1416152
You should use next code:

WIN32_FILE_ATTRIBUTE_DATA *wfad;
GetFileAttributesEx ("d:/any.txt", GetFileExInfoStandard, &wfad);

I just tried it in VC++ and didn't work, I got next message:
"Cannot execute TEST.EXE .... linked to Kernel32.GetFileAttributesEx ... does not exist."
Althoug I had no problems while compiling. There could be something wrong with my Kernel (or maybe a bad version).

Anyway, if it doesn't work with you then I accept I couldn't help very much, so you can reject my answer.

Trillo.
0
 
LVL 1

Expert Comment

by:hustch
ID: 1416153
I've had the same problem, and GetFileAttributesEx is the fastest way, but it only works in Windows NT, not Windows 95.

I use CreateFile/GetFileTime, which is a lot faster than than FindFirst. You can pass a zero for dwDisiredAccess to CreateFile if you need to minimize sharing problems.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question