尽管我在网上搜索过,但没有任何像我这样的问题。我的问题是,我想获取目录中最后创建的文件的名称。我的系统将在该代码的目录中创建来自我的相机的 /.png 文件,我希望我的代码采用最后创建的文件。我想用这段代码来做,
string processName()
{
// FILETIME Date = { 0, 0 };
// FILETIME curDate;
long long int curDate = 0x0000000000000000;
long long int date = 0x0000000000000000;
//CONST FILETIME date={0,0};
//CONST FILETIME curDate={0,0};
string name;
CFileFind finder;
FILETIME* ft;
BOOL bWorking = finder.FindFile("*.png");
while (bWorking)
{
bWorking = finder.FindNextFile();
date = finder.GetCreationTime(ft) ;
//ftd.dwLowDateTime = (DWORD) (date & 0xFFFFFFFF );
//ftd.dwHighDateTime = (DWORD) (date >> 32 );
if ( CompareFileTime(date, curDate))
{
curDate = date;
name = (LPCTSTR) finder.GetFileName();
}
}
return name;
}
我没有使用额外的库,而是使用了以下库,可以在链接中看到:
https://msdn.microsoft.com/en-US/library/67y3z33c(v=vs.80).aspx https://msdn.microsoft.com/en-US/library/67y3z33c(v=vs.80).aspx
在此代码中,我尝试为 64 位 FILETIME 变量赋予初始值,并将它们与此 while 循环进行比较。但是我收到以下错误。
1 IntelliSense: argument of type "long long" is incompatible with parameter of type "const FILETIME *" 44 25
2 IntelliSense: argument of type "long long" is incompatible with parameter of type "const FILETIME *" 44 31
getCreationTime 方法采用一个参数作为
参数:
pTimeStamp:指向包含文件创建时间的 FILETIME 结构的指针。
refTime:对 CTime 对象的引用。