Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
Time
Time Reference
Time Functions
 CompareFileTime function
CompareFileTime function

Applies to: desktop apps only

Compares two file times.

Syntax

LONG WINAPI CompareFileTime(
  __in  const FILETIME *lpFileTime1,
  __in  const FILETIME *lpFileTime2
);

Parameters

lpFileTime1 [in]

A pointer to a FILETIME structure that specifies the first file time.

lpFileTime2 [in]

A pointer to a FILETIME structure that specifies the second file time.

Return value

The return value is one of the following values.

Return valueDescription
-1

First file time is earlier than second file time.

0

First file time is equal to second file time.

1

First file time is later than second file time.

 

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

GetFileTime
File Times
FILETIME
Time Functions

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Tip: for memorizing.      Ujjwal Singh 013   |   Edit   |   Show History
Think of (-1) as "Negative", thus (+1) => "Positive". Such that: if 1stFTime is larger and later than 2ndFTime result will be "Positive" viz (+1)
Tags What's this?: Add a tag
Flag as ContentBug
C#      mhubal   |   Edit   |   Show History
[DllImport("kernel32.dll")]
public static extern int CompareFileTime(ref System.Runtime.InteropServices.ComTypes.FILETIME lpFileTime1, ref System.Runtime.InteropServices.ComTypes.FILETIME lpFileTime2);
Tags What's this?: Add a tag
Flag as ContentBug
Pc timer      Pc timer   |   Edit   |   Show History
the best one i know
Tags What's this?: Add a tag
Flag as ContentBug
CompareFileTime may return 1 or -1 when invoked with two files that are the same      Daniel Martín   |   Edit   |   Show History
The scenario is that you move a file from an NTFS drive to a FAT drive and pass both FILETIME structures to CompareFileTime. It will NOT return 0 because file times are stored with 10 ms granularity in FAT and with 100 ns granularity in NTFS. When you move a file from an NTFS drive to a FAT drive, its time is rounded down.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker