Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,244 questions

52,261 answers

573 users

How to compare two file times in C Win32 API

1 Answer

0 votes
#include <windows.h>
#include <stdio.h>

// LONG CompareFileTime(const FILETIME* lpFileTime1, const FILETIME* lpFileTime2);

/*
typedef struct _FILETIME {
  DWORD dwLowDateTime;
  DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;

// Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).

*/

int main() {
    FILETIME fileTime1, fileTime2;

    // Example: Initialize FILETIME structures with arbitrary values
    fileTime1.dwLowDateTime = 200000000;
    fileTime1.dwHighDateTime = 0;

    fileTime2.dwLowDateTime = 100000000;
    fileTime2.dwHighDateTime = 0;

    // Compare the two FILETIME structures
    LONG result = CompareFileTime(&fileTime1, &fileTime2);

    if (result < 0) {
        printf("fileTime1 < fileTime2.\n");
    }
    else if (result == 0) {
        printf("fileTime1 == fileTime2.\n");
    }
    else {
        printf("fileTime1 > fileTime2.\n");
    }

    return 0;
}



/*
run

fileTime1 > fileTime2.

*/

 



answered May 13, 2025 by avibootz
...