返回列表 发帖
xp 实测好像没有问题,回家用 win7 试下

TOP

回复 6# xxpinqz


    我勒个去,看撸主 ID 是不会干这种事的...是吧?是吧?

TOP

本帖最后由 CrLf 于 2014-9-30 17:55 编辑

用 tcc 试了下,好像 _findfirst 和 FindNextFile 都存在此问题,但奇怪的是和 dir 的输出又有那么点不太一样
#include <windows.h>
#include <winbase.h>
#include <io.h>
int by_findfirst(char *path){
    struct _finddata_t FileInfo;
    long Handle;
    int i=0;
    if((Handle=_findfirst(path,&FileInfo))!=-1L)
    {
        while(!_findnext(Handle,&FileInfo))printf("%s\n",FileInfo.name,i++);
        _findclose(Handle);
    }
    return i;
}
int byFindFirstFile(char *path){
    WIN32_FIND_DATA FileInfo;
    long Handle;
    int i=0;
    if((Handle=FindFirstFile(path,&FileInfo))!=-1L){
        while(FindNextFile(Handle,&FileInfo))printf("%s\n",FileInfo.cFileName,i++);
        FindClose(Handle);
    }
    return i;
}
int main()
{
    char path[999] = "352*.png";
    printf("\n_findfirst 共 %d 个结果\n\n",by_findfirst(path));
    printf("\nFindNextFile 共 %d 个结果\n\n",byFindFirstFile(path));
    return 0;
}COPY
输出:
356话_005.png
352话_001.png
352话_002.png
352话_003.png
352话_004.png
352话_005.png

_findfirst 共 6 个结果

356话_005.png
352话_001.png
352话_002.png
352话_003.png
352话_004.png
352话_005.png

FindFirstFile 共 6 个结果

而 dir 352*.png 的结果是:
2014/09/29  14:53                 3 355话_005.png
2014/09/29  14:53                 3 356话_005.png
2014/09/29  14:53                 3 352话_001.png
2014/09/29  14:53                 3 352话_002.png
2014/09/29  14:53                 3 352话_003.png
2014/09/29  14:53                 3 352话_004.png
2014/09/29  14:53                 3 352话_005.png
               7 个文件             21 字节

TOP

返回列表