C++ 使用C++;在窗户上

C++ 使用C++;在窗户上,c++,windows,filesystems,stat,C++,Windows,Filesystems,Stat,我需要使用cpp在windows中对文件进行修改时间,创建时间和更改时间。我正在使用以下代码: string filename = "D:\\hi.txt"; struct stat result; if (stat(filename.c_str(), &result) == 0) { int a = 10; auto mod_time = result.st_mtime; cout << "modified time is: "<<mod

我需要使用cpp在windows中对文件进行
修改时间
创建时间
更改时间
。我正在使用以下代码:

string filename = "D:\\hi.txt";
struct stat result;
if (stat(filename.c_str(), &result) == 0)
{
    int a = 10;
    auto mod_time = result.st_mtime;
    cout << "modified time is: "<<mod_time<<endl;
}
string filename=“D:\\hi.txt”;
结构统计结果;
if(stat(filename.c_str(),&result)==0)
{
INTA=10;
自动修改时间=result.st\u mtime;

coutMSDN为文件定义了三个时间戳:创建时间、上次访问时间、上次写入时间。您要求的实际上是上次访问时间

在您的示例中,您使用了一个Libc函数,该函数适用于所有具有C编译器的系统。因此,它可能过于通用,即它不代表特定环境(在您的示例中为MS Windows)中可用的所有功能,而仅代表通用属性的子集


在这里,您可以找到
GetFileTime()的描述
WinAPI函数,该函数返回Windows支持的文件时间。如果您编写的应用程序不打算移植到其他平台,则最好使用WinAPI进行系统级操作。

考虑到Windows没有与Linux相同的权限位集,更改时间意味着什么?