-1

I can use WinApi CreateDirectory to create a directory. How do I set the directory's properties like creation time, last access time and last write time?

Asesh
  • 3,186
  • 2
  • 21
  • 31
zet
  • 169
  • 10
  • I believe [this](https://stackoverflow.com/questions/9235679/create-a-directory-if-it-doesnt-exist) topic can help you. – WillEnsaba Jan 04 '18 at 09:52
  • 2
    10 seconds of googling showed me you need the [SetFileTime](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724933(v=vs.85).aspx) function – Jabberwocky Jan 04 '18 at 09:58

1 Answers1

2

The SetFileTime API call can be used with files as well as directories. The first parameter is documented as:

hFile: A handle to the file or directory.

IInspectable
  • 46,945
  • 8
  • 85
  • 181
  • Thanks! I think SetFileTime can work. But I have another question: how to get a directory's handle? Maybe CreateFile can be used to get the directory's handle? – zet Jan 05 '18 at 09:04
  • @zet: Yes, `CreateFile` can be used to get a handle to a directory, as [documented](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724933.aspx). – IInspectable Jan 05 '18 at 19:29