当前位置:网站首页>_ FindText error

_ FindText error

2022-04-23 17:53:00 ppipp1109

ps: Compile environment qt + mingw32 No problem compiling ;

Switch to qt + msvc 2017_64 There's a problem ;

Error message :

Stopped in thread 0 by: Exception at 0x7ffbcfe713ad, code: 0xc0000005: write access violation at: 0xffffffffd587d380, flags=0x0 (first chance).

// Get all file names in the directory 
void getFiles(string path, vector<string>& files)
{
    // File handle 
    long hFile = 0;
    // file information 
    struct _finddata_t fileinfo;
    string p;
    if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1)
    {
        do
        {
            // If it's a catalog , Iterative 
            // If not , Join list 
            if ((fileinfo.attrib & _A_SUBDIR))
            {
                if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
                    getFiles(p.assign(path).append("\\").append(fileinfo.name), files);
            }
            else
            {
                files.push_back(p.assign(path).append("\\").append(fileinfo.name));
            }
        } while (_findnext(hFile, &fileinfo) == 0);
        _findclose(hFile);
    }
}

When applying the following function , Report the error above . Tossed all afternoon , At first, I thought it was a coding format problem , The final discovery is 64 Bit compiler , The value of the feedback structure is 64 position , Defined long type hFile Will be cut off , Not right .

So will long hfile Change it to

intptr_t hFile 
 perhaps  
long long hFIle

版权声明
本文为[ppipp1109]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230549075533.html