//flex table opened by JP

Click to See Complete Forum and Search --> : Getting information about a .jpeg file


nothing
07-29-2004, 10:25 PM
Using C++, I need to get information on when a .jpeg file was created. Can somebody help me? Thanks a lot!

CompGeek01
07-30-2004, 08:45 AM
Only thing I could find was a .NET framework class....

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiofileclassgetcreationtimetopic.asp


If you find a really easy and simple way I'd love to know...been wanting something like this for a bit. ;)

fishybawb
07-30-2004, 10:20 AM
You could parse through the output of a "dir" or "ls" command I guess, apart from that you'd be looking at some inline assembly.

nothing
07-30-2004, 11:37 AM
I think I almost got it. I'll keep you guys informed.

nothing
07-30-2004, 03:14 PM
I think I got it guys:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HANDLE hFile = hFile = CreateFile(TEXT("d:\\sns.txt"), // file to open
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // default security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template

FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;

// Retrieve the file times for the file.
GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite);

// Convert the last-write time to local time.
FileTimeToSystemTime(&ftWrite, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);

// Build a string showing the date and time.
printf("%02d/%02d/%d %02d:%02d",
stLocal.wMonth, stLocal.wDay, stLocal.wYear,
stLocal.wHour, stLocal.wMinute);

getchar();

return 0;
}


My output:

07/29/2004 14:59


:D

nothing
07-30-2004, 03:26 PM
No, it is not working with .jpeg files :(

CompGeek01
07-31-2004, 12:57 AM
what kind of files DOES it work with?

nothing
07-31-2004, 02:04 AM
That one works with .txt files. This one works with jpg files and might work with other file types too.


#include <windows.h>
#include <stdio.h>

int main(){
HANDLE hFile = CreateFile(TEXT("c:\\schloob.jpg"),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);

FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;


GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite);


FileTimeToSystemTime(&ftWrite, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);

printf("%02d/%02d/%d %02d:%02d",
stLocal.wMonth, stLocal.wDay, stLocal.wYear,
stLocal.wHour, stLocal.wMinute);

CloseHandle(hFile);

getchar();

return 0;
}