Getting created, last accessed and last modified times from locked files in C++
<p>I am currently trying to fix a bug on a legacy application code in which it uses basically <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724320(v=vs.85).aspx" rel="nofollow noreferrer">GetFileTime</a> function to retrieve file information through a <code>HANDLE</code> obtained by using <code>CreateFileW</code> function.</p>

<p>Problem arises when it attempts to work with files that are already opened by other processes like <code>*.ldf</code> and <code>*.mdf</code> files which are opened by <code>SQL Server</code>. An error is thrown when trying to get the file <code>HANDLE</code>.</p>

<p>As an alternative, I noticed that <code>boost</code> library is being used as a dependency in the project so I found the following code sample working:</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;boost/filesystem.hpp&gt;

using namespace boost::filesystem;

path filePath("path/to/the/file.ext");

std::cout &lt;&lt; file_size(filePath) &lt;&lt; "\n"; // Getting file size
std::cout &lt;&lt; last_write_time(filePath) &lt;&lt; "\n"; // Getting write/modified time
</code></pre>

<p>Using that piece of code we get the file size and the last write time. However, I <strong>still need the created and last accessed times</strong>. Any ideas how can I achieve it?</p>