how can ı get last access time without framework?? ı know GetLastAccessTime(file) but it runs on framework..
how can ı get last access time without framework?? ı know GetLastAccessTime(file) but it runs on framework..
thank you so much.. but ı have one more problem.. ı get it but ı want compare first and second file.. smaller or bigger??.. but if ı write in "if(deneme1>deneme2)" ı get problem.. ı think ı must convert to other file because ı get time in FILETIME... can you give advice??
I GET THIS ERROR
--------------------Configuration: ccc - Win32 Debug--------------------
Compiling...
ccc.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\ccc\ccc.cpp(285) : error C2664: 'ctime' : cannot convert parameter 1 from 'struct _FILETIME *' to 'const long *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\ccc\ccc.cpp(285) : error C2664: 'ctime' : cannot convert parameter 1 from 'struct _FILETIME *' to 'const long *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
ccc.exe - 2 error(s), 0 warning(s)
Yes, FILETIME from Microsofts API is not the same as "time_t" for example.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
How about showing us the code you are using that generates these errors?
sory.. ı wrote it..Code:FILETIME son,temptime; if(ilk==0) { ilk++; GetFileTime(&hFind,NULL,NULL,&son); } GetFileTime(&hFind,NULL,NULL,&temptime); if(ctime(&temptime)>ctime(&son))
As long as the files you are comparing are on the same system, you should be able to compare the time by simply moving the low and high part of the FILETIME (described here:http://msdn.microsoft.com/en-us/libr...84(VS.85).aspx) into a ULARGE_INTEGER, and then compare the quadpart of the ULARGE_INTEGER variables.
If you are using getting files from a network, you could also need to (potentially - but this starts to get very tricky) for the possibility that the files are in different timezones and/or the systems have different system times set.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I couldn't do this can anybody help to me?? I write simple example about my code :
can we compare soN and temptimE with if?? like this:Code:FILETIME son,temptime; SYSTEMTIME sonn,temptimee,soN,temptimE; ...... GetFileTime(&hFind,NULL,NULL,&son); FileTimeToSystemTime(&son, &sonn); SystemTimeToTzSpecificLocalTime(NULL, &sonn, &soN); ...... GetFileTime(&hFind,NULL,NULL,&temptime); FileTimeToSystemTime(&temptime, &temptimee); SystemTimeToTzSpecificLocalTime(NULL, &temptimee, &temptimE);
ofcourse this is falseCode:if(temptimE>soN) MessageBox(NULL, FindFileData.cFileName, "UYARI", NULL);
They aren't helping because you are posting on the wrong forum! You are asking a platform specific question on the forum for people who write portable code (or so the theory goes).
[edit] I am making this function special, just for you [/code]
Example:
I changed it only because it allows you to be portable. Now you are posting on the correct forumCode:#include <string> #include <cstring> #include <windows.h> #include <ctime> /* Note that by including windows.h you should automatically be directing * questions to the windows forums, not this one. */ #define MAGICAL1 11644473600 #define MAGICAL2 10000000 time_t GetLastAccessTime(const std::string &filename) { time_t t = 0; ULARGE_INTEGER uli; FILETIME ft; HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, 0, 0, 0, OPEN_EXISTING, 0, 0); if(hFile != INVALID_HANDLE) { BY_HANDLE_FILE_INFORMATION info; if(GetFileInformationByHandle(hFile, &info)) { FileTimeToLocalFileTime(&info.ftLastAccessTime, &ft); uli.HighPart = ft.ftLastAccessTime.dwHighDateTime; uli.LowPart = ft.ftLastAccessTime.dwLowDateTime; uli.QuadPart /= MAGICAL2; t = (time_t)(uli.QuadPart - MAGICAL1); } CloseFile(hFile); } return t; }
Last edited by master5001; 05-08-2008 at 06:03 PM.