Click here to Skip to main content
15,883,758 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?

C++
#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

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.
 
Share this answer
 
Comments
Member 7766180 30-Sep-11 23:27pm    
Thank you. Any solution to this overall problem then?
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.
 
Share this answer
 
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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900