Click here to Skip to main content
14,576,970 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm trying to do conversions between Filetime and Systemtime and I'm getting an Error C2039 that OneMinuteAgo is not a meber of class FILETIME. What am I doing wrong? And how can I fix this?

#include string 
#include vector
#include windows.h
#include time.h 
#include map
struct file_data 
{ 
    std::wstring sLastAccessTime; 
    __int64 nFileSize      ; 
};

int GetFileList(const wchar_t *searchkey, std::map &map) 
{ 
    WIN32_FIND_DATA fd; 
    HANDLE h = FindFirstFile(searchkey,&fd); 
    if(h == INVALID_HANDLE_VALUE) 
    { 
        return 0; // no files found 
    } 
    while(1) 
    { 
       	wchar_t buf[128]; 
        SYSTEMTIME st;
	FILETIME ftNow;
	LARGE_INTEGER li;    
	GetSystemTime(&st);
	SystemTimeToFileTime(&st, &ftNow);
    	li.LowPart = ftNow.dwLowDateTime;
        li.HighPart = ftNow.dwHighDateTime;
		
	GetSystemTimeAsFileTime(&ftNow);
	auto ftAs64 = ftNow.OneMinuteAgo.dwLowDateTime + ((unsigned__int64)         ftNow.OneMinuteAgo.dwHighDateTime << 32) - 6000000000UL;

FILETIME ftOneMinuteAgo = { (DWORD)ftAs64, (DWORD)(ftAs64 >> 32) };
FileTimeToSystemTime(&ftNow, &st); 
wsprintf(buf, L"%d-%02d-%02d",st.wYear, st.wMonth, st.wDay); 
		
file_data filedata; 
filedata.sLastAccessTime= buf; 
filedata.nFileSize      = (((__int64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow; 
 
        map[fd.cFileName]= filedata; 
 
        if (FindNextFile(h, &fd) == FALSE) 
            break; 
    } 
     FindClose(h);
return map.size(); 
}
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 2

When you're assigning a value to ftAs64, you're trying to access OneMinuteAgo as a member of ftNow.

ftNow only has 2 members, dwLowDateTime and dwHighDateTime.
   
Comments
Member 7766180 30-Sep-11 23:27pm
   
Thank you. Any solution to this overall problem then?
Rate this:
Please Sign up or sign in to vote.

Solution 1

You declared:
FILETIME ftNow;

then you tried to access a member variable named OneMinuteAgo by using it like this:
ftNow.OneMinuteAgo.dwLowDateTime //In more than one place

If FILETIME is the structure I think it is:
typedef struct _FILETIME {
  DWORD dwLowDateTime;
  DWORD dwHighDateTime;
} FILETIME, *PFILETIME;

...then as you can clearly see, there's no such thing as OneMinuteAgo in there.
   
Comments
Member 7766180 30-Sep-11 23:27pm
   
I see, so what can I do to make this code work I'm sure that you have seen my post on looking for files that are less than a minute old. Albert any help that you can give I'd appreciate. Thank you.
Albert Holguin 30-Sep-11 23:37pm
   
I've told you the problem, it should be easy to fix. I'm noticing you're not doing anything to fix your problems and waiting for code handouts. Sorry, but you're not going to get it from me.
Member 7766180 30-Sep-11 23:46pm
   
Albert, I did fix it. I removed it and the code compiled. "Waiting for code handouts" I expected more from you. That wasn't very nice. You don't know how much reading and googling I do to come up with solutions. Do you think I just post, go have some iced tea, then check for an answer. You are sadly mistaken. I really thought that you were better than that. (You act like it's a sin to post code) I've given away a lot of VB code to people in need, and guess what, IT FELT GOOD to help.
Member 7766180 30-Sep-11 23:46pm
   
GetSystemTimeAsFileTime(&ftNow);
auto ftAs64 = ftNow.dwLowDateTime + ((unsigned __int64)ftNow.dwHighDateTime << 32) - 6000000000UL;
FILETIME ftOneMinuteAgo = { (DWORD)ftAs64, (DWORD)(ftAs64 >> 32) };
FileTimeToSystemTime(&ftNow, &st);
wsprintf(buf, L"%d-%02d-%02d",st.wYear, st.wMonth, st.wDay);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100