How to extract "Date column" value for a specific file for Windows 7 x64, in C++

Nick

I want to extract the Date value for a specific file and compare it with Date Modified and Date Created, in Visual C++.

I've seen that I can extract Date Created and Date Modified, but I don't know anything about Date.

I've altered some files with a buggy software, and the only column that still has a valid time is the Date one. How can I extract it?

I'm using Windows 7 x64.

Here, I've seen only st_atime, st_ctime, st_mtime: http://msdn.microsoft.com/en-us/library/14h5k7ff.aspx

Jonathan Potter

Windows stores three timestamps for each file or folder:

  • Creation time (the time/date the item was first created)
  • Last modification time (the time the file was last written to)
  • Last access time (the time the file was last accessed)

There are a number of ways to read these timestamps, but using the native Win32 API you can do the following:

LPCWSTR pszFileName = L"c:\\path\\to\\myfile.txt";
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(pszFileName, &wfd);
if (hFind != INVALID_HANDLE_VALUE)
{
    FindClose(hFind);
    // timestamps can now be found at:
    // wfd.ftCreationTime
    // wfd.ftLastAccessTime
    // wfd.ftLastWriteTime
}

You can use functions like FileTimeToSystemTime() to convert the FILETIME values (which are simply a tick count since a specific date) into more usable SYSTEMTIME structures which give you day, month, year, hour, minute, etc.

Note: "Last modification time" is also updated for folders, as well as files, and indicates the last time a file was modified directly inside that folder. Changes to folder timestamps are not propagated to parent folders.

Note 2: "Last access time" is more or less deprecated, and is disabled by default in newer versions of Windows. You can enable it using a registry setting.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I share a printer on Windows 7 x64 with Windows XP x86?

分類Dev

How to read and extract specific text from a .txt file in c

分類Dev

Windows 7 x64 Pro not indexing PDF content?

分類Dev

Extract a value from a text file in a specific position

分類Dev

Can I install windows 7 x64 in a VPC where the host is vista x86?

分類Dev

EnumWindowのWindows7 x64のバグ?

分類Dev

Phalcon: Unable to initialize module Module compiled with build windows 7 x64 Zend Server

分類Dev

Problem with resolution of Ubuntu 14 on Windows7 x64 Virtualbox5

分類Dev

How to parse/extract specific values from an input huge file in python?

分類Dev

How can I get Cisco VPN to work on Windows 8 x64?

分類Dev

How to attach VHDX file on Windows 7?

分類Dev

Does the SystemFolder property always transform its value depending on the Windows platform, i.e. x64 or x86?

分類Dev

How extract a specific character in a string in c# by index

分類Dev

Ubuntu 13.10x64とWindows7 Ultimate N x64のデュアルブート?

分類Dev

Ubuntu 13.10x64とWindows7 Ultimate N x64のデュアルブート?

分類Dev

libsodium + Windows 10 x64 + Eclipse

分類Dev

How to Unzip a file and copy it to specific location with 7zip?

分類Dev

Apple MagicMouseはWindows7 x86 / x64で完全に動作しますか?

分類Dev

Windows7のC ++ CreateProcessエラーコード2( "ERROR_FILE_NOT_FOUND")(64)

分類Dev

Confused about Windows 7 64-bit page file with SSD

分類Dev

Extract specific words from text value

分類Dev

Extract Specific Parameter value using Regex Postgresql

分類Dev

OSError: cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll': error 0x7e

分類Dev

Windows 7 x64 ProはPDFコンテンツのインデックスを作成しませんか?

分類Dev

別々のパーティションにダブルインストールされたWindows7 x64

分類Dev

pipがWindows7 x64、Python2.7にpylzmaをインストールする方法

分類Dev

Windows 7 x64(Meteor 0.8.3)でのiron-router(最新)のインストールの問題

分類Dev

Windows 7 Pro x64、Intel eXensible 3.0ドライバー、および動作しないUSB(ほぼ)

分類Dev

How can i run php file automatically in windows7

Related 関連記事

  1. 1

    How can I share a printer on Windows 7 x64 with Windows XP x86?

  2. 2

    How to read and extract specific text from a .txt file in c

  3. 3

    Windows 7 x64 Pro not indexing PDF content?

  4. 4

    Extract a value from a text file in a specific position

  5. 5

    Can I install windows 7 x64 in a VPC where the host is vista x86?

  6. 6

    EnumWindowのWindows7 x64のバグ?

  7. 7

    Phalcon: Unable to initialize module Module compiled with build windows 7 x64 Zend Server

  8. 8

    Problem with resolution of Ubuntu 14 on Windows7 x64 Virtualbox5

  9. 9

    How to parse/extract specific values from an input huge file in python?

  10. 10

    How can I get Cisco VPN to work on Windows 8 x64?

  11. 11

    How to attach VHDX file on Windows 7?

  12. 12

    Does the SystemFolder property always transform its value depending on the Windows platform, i.e. x64 or x86?

  13. 13

    How extract a specific character in a string in c# by index

  14. 14

    Ubuntu 13.10x64とWindows7 Ultimate N x64のデュアルブート?

  15. 15

    Ubuntu 13.10x64とWindows7 Ultimate N x64のデュアルブート?

  16. 16

    libsodium + Windows 10 x64 + Eclipse

  17. 17

    How to Unzip a file and copy it to specific location with 7zip?

  18. 18

    Apple MagicMouseはWindows7 x86 / x64で完全に動作しますか?

  19. 19

    Windows7のC ++ CreateProcessエラーコード2( "ERROR_FILE_NOT_FOUND")(64)

  20. 20

    Confused about Windows 7 64-bit page file with SSD

  21. 21

    Extract specific words from text value

  22. 22

    Extract Specific Parameter value using Regex Postgresql

  23. 23

    OSError: cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll': error 0x7e

  24. 24

    Windows 7 x64 ProはPDFコンテンツのインデックスを作成しませんか?

  25. 25

    別々のパーティションにダブルインストールされたWindows7 x64

  26. 26

    pipがWindows7 x64、Python2.7にpylzmaをインストールする方法

  27. 27

    Windows 7 x64(Meteor 0.8.3)でのiron-router(最新)のインストールの問題

  28. 28

    Windows 7 Pro x64、Intel eXensible 3.0ドライバー、および動作しないUSB(ほぼ)

  29. 29

    How can i run php file automatically in windows7

ホットタグ

アーカイブ