R
Rijaalu
Guest
Hello Everyone,
I am working on a Face Recognition project. I need help on retrieving the dateTimeStamp of images in batch. I found this code on one of the msdn forums, which can only retrieve a single image DateTimeStamp, so I would need help on how to extend it to retrieve multiple images at once.
Code:
// GetDateTime.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include <string.h>
#include <iostream>
#include <fstream>
using namespace std;
std::string;
// GetLastWriteTime - Retrieves the last-write time and converts
// the time to a string
//
// Return value - TRUE if successful, FALSE otherwise
// hFile - Valid file handle
// lpszString - Pointer to buffer to receive string
BOOL GetLastWriteTime(HANDLE hFile, LPTSTR lpszString, DWORD dwSize)
{
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;
DWORD dwRet;
// Retrieve the file times for the file.
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
return FALSE;
// Convert the last-write time to local time.
FileTimeToSystemTime(&ftWrite, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
// Build a string showing the date and time.
dwRet = StringCchPrintf(lpszString, dwSize,
TEXT("%02d/%02d/%d %02d:%02d"),
stLocal.wMonth, stLocal.wDay, stLocal.wYear,
stLocal.wHour, stLocal.wMinute);
if( S_OK == dwRet )
return TRUE;
else return FALSE;
}
int _tmain(int argc, TCHAR *argv[])
{
HANDLE hFile;
TCHAR szBuf[MAX_PATH];
TCHAR* path = "C:\\Users\\rijaalu\\Desktop\\CamCaptureImages\\Modou\\7.jpg";
string s = path;
hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed with %d\n", GetLastError());
return 0;
}
if(GetLastWriteTime( hFile, szBuf, MAX_PATH ))
_tprintf(TEXT("Last write time is: %s\n\n"), szBuf);
CloseHandle(hFile);
system("PAUSE");
return 0;
}
Continue reading...
I am working on a Face Recognition project. I need help on retrieving the dateTimeStamp of images in batch. I found this code on one of the msdn forums, which can only retrieve a single image DateTimeStamp, so I would need help on how to extend it to retrieve multiple images at once.
Code:
// GetDateTime.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include <string.h>
#include <iostream>
#include <fstream>
using namespace std;
std::string;
// GetLastWriteTime - Retrieves the last-write time and converts
// the time to a string
//
// Return value - TRUE if successful, FALSE otherwise
// hFile - Valid file handle
// lpszString - Pointer to buffer to receive string
BOOL GetLastWriteTime(HANDLE hFile, LPTSTR lpszString, DWORD dwSize)
{
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;
DWORD dwRet;
// Retrieve the file times for the file.
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
return FALSE;
// Convert the last-write time to local time.
FileTimeToSystemTime(&ftWrite, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
// Build a string showing the date and time.
dwRet = StringCchPrintf(lpszString, dwSize,
TEXT("%02d/%02d/%d %02d:%02d"),
stLocal.wMonth, stLocal.wDay, stLocal.wYear,
stLocal.wHour, stLocal.wMinute);
if( S_OK == dwRet )
return TRUE;
else return FALSE;
}
int _tmain(int argc, TCHAR *argv[])
{
HANDLE hFile;
TCHAR szBuf[MAX_PATH];
TCHAR* path = "C:\\Users\\rijaalu\\Desktop\\CamCaptureImages\\Modou\\7.jpg";
string s = path;
hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed with %d\n", GetLastError());
return 0;
}
if(GetLastWriteTime( hFile, szBuf, MAX_PATH ))
_tprintf(TEXT("Last write time is: %s\n\n"), szBuf);
CloseHandle(hFile);
system("PAUSE");
return 0;
}
Continue reading...