本文介绍了wstring未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在得到错误,wstring未定义.这是什么罪魁祸首?如何解决?它就行了..... wstring sLastAccessTime;

I''m getting and error that wstring is undefined. What is cusing this? How can it be fixed? Its on the line.....wstring sLastAccessTime;

#include <string>
#include <vector>
#include <windows.h>
#include <time.h>
#include <map>

struct file_data
{
    wstring sLastAccessTime;
    __int64 nFileSize      ;
};

int GetFileList(const wchar_t *searchkey, std::map<std::wstring, file_data> &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];
        FILETIME ft = fd.ftLastWriteTime;
        SYSTEMTIME sysTime;
        FileTimeToSystemTime(&ft, &sysTime);
        wsprintf(buf, L"%d-%02d-%02d",sysTime.wYear, sysTime.wMonth, sysTime.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;
    }
    return map.size();
}

int main()
{
    std::map<std::wstring, file_data> map;
    GetFileList(L"C:\\Users\\DS\\Downloads\\*.zip", map);
    GetFileList(L"C:\\Users\\DS\\Downloads\\*.txt", map);

    for(std::map<std::wstring, file_data>::const_iterator it = map.begin();
        it != map.end(); ++it)
    {
        MessageBoxW(NULL,it->first.c_str(),L"File Name",MB_OK);
        MessageBoxW(NULL,it->second.sLastAccessTime.c_str(),L"File Date",MB_OK);
    }

    return 0;
}

推荐答案



这篇关于wstring未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:09