void GetCapNum(int * todayNum, int * mouthNum) {
string path = ".\\res";//路径位于程序运行目录下的res文件夹里面
string exd = "png";//提取png后缀名的文件
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string pathName, exdName;
if (0 != strcmp(exd.c_str(), ""))
{
exdName = "\\face*." + exd;//所有face*.png的文件 如果是\\*.png 就是所有的png文件
}
else
{
exdName = "\\face*";//所有face*.png的文件 如果是\\*.png 就是所有的png文件
}
printf("get current time %s\n" , pathName.assign(path).append(exdName).c_str());
if ((hFile = _findfirst(pathName.assign(path).append(exdName).c_str(), &fileinfo)) != -1)
{
//获取当前时间
time_t* mptr_currentSeconds = new time_t;
time(mptr_currentSeconds);
struct tm* m_localTime = localtime(mptr_currentSeconds);
printf("current Local time : %d:%d:%d\n", m_localTime->tm_hour, m_localTime->tm_min, m_localTime->tm_sec);
do
{
//如果是文件夹中仍有文件夹,迭代之
//如果不是,加入列表
/**
if ((fileinfo.attrib & _A_SUBDIR))
{
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
getFiles(pathName.assign(path).append("\\").append(fileinfo.name), exd, files);
}
else
{**/
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) {
HANDLE picFile = 0;
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME createTimeUTC, createTimeLocal;
//files.push_back(pathName.assign(path).append("\\").append(fileinfo.name));
string picpath = ".\\res\\";
picpath = picpath.append(fileinfo.name);
char *pth = (char *)picpath.data();
//获取图片的创建时间
printf("CreateFile %s \n",pth);
//picFile = CreateFile("D:\\dev\\fmt\\res\\face1.png", 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
picFile = CreateFile(pth, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == picFile) {
printf("CreateFile error: %d", GetLastError());
continue;
//ExitProcess(0);
}
GetFileTime(picFile, &ftCreate, &ftAccess, &ftWrite);
FileTimeToSystemTime(&ftCreate, &createTimeUTC);
SystemTimeToTzSpecificLocalTime(NULL, &createTimeUTC, &createTimeLocal);
printf("创建时间:\t%02d/%02d/%d %02d:%02d \n",
createTimeLocal.wDay, createTimeLocal.wMonth, createTimeLocal.wYear,
createTimeLocal.wHour, createTimeLocal.wMinute);
if ((createTimeLocal.wDay == m_localTime->tm_yday) && (createTimeLocal.wMonth == m_localTime->tm_mon) && (createTimeLocal.wYear == m_localTime->tm_year)) {
*todayNum = *todayNum + 1;
}
*mouthNum = *mouthNum + 1;
}
//}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}