错误C2039不是成员 [英] Error C2039 Is Not A Member Of

查看:167
本文介绍了错误C2039不是成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Filetime和Systemtime之间进行转换,并且出现错误C2039,表明OneMinuteAgo不是FILETIME类的成员.我究竟做错了什么?我该如何解决呢?

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(); 
}

推荐答案

为ftAs64分配值时,您试图以ftNow成员的身份访问OneMinuteAgo. >
ftNow只有2个成员dwLowDateTime和dwHighDateTime.
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.


您声明:
FILETIME ftNow;


那么您尝试使用如下方式访问名为OneMinuteAgo的成员变量:


then you tried to access a member variable named OneMinuteAgo by using it like this:

ftNow.OneMinuteAgo.dwLowDateTime //In more than one place


如果FILETIME是结构,我认为是:


If FILETIME is the structure I think it is:

typedef struct _FILETIME {
  DWORD dwLowDateTime;
  DWORD dwHighDateTime;
} FILETIME, *PFILETIME;


...然后您可以清楚地看到,其中没有OneMinuteAgo这样的东西.


...then as you can clearly see, there''s no such thing as OneMinuteAgo in there.


这篇关于错误C2039不是成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆