我的VC里有段移植的代码要用到这两个函数,TC的dir.h和dos.h里也没有?那位大哥知道是怎么写的?

解决方案 »

  1.   

    LZ 要的是
    _findfirst 
    _findnext 么?
    看MSDN是否是想要的
      

  2.   

    希望有findfirst()函数和findnext()函数的代码
      

  3.   

    VC:
    long handle; 
    struct _finddata_t filestruct;   
    char path_search[_MAX_PATH]; 
    handle = _findfirst("目录",&filestruct); 
    if((handle == -1)) return; 
    if( ::GetFileAttributes(filestruct.name)& FILE_ATTRIBUTE_DIRECTORY ) 

    if( filestruct.name[0] != '.' ) 

    _chdir(filestruct.name); 
    Search_Directory(szFilename); 
    _chdir(".."); 


    else

    if( !stricmp(filestruct.name, szFilename) ) 

    strcat(path_search,"\\"); 
    strcat(path_search,filestruct.name); 
    MessageBox(path_search);


    while(!(_findnext(handle,&filestruct))) 

      if( ::GetFileAttributes(filestruct.name) &FILE_ATTRIBUTE_DIRECTORY ) 

    if(*filestruct.name != '.') 

    _chdir(filestruct.name); 
    Search_Directory(szFilename); 
    _chdir(".."); 

    else 

    if(!stricmp(filestruct.name,szFilename)) 

    _getcwd(path_search,_MAX_PATH); 
    strcat(path_search,"\\"); 
    strcat(path_search,filestruct.name); 
    MessageBox(path_search); 



    _findclose(handle); 
      

  4.   

    谢谢jixingzhong ,_findfirst、_finddata_t是在那里定义的呢?
      

  5.   

    你做DOS程序还是做Windows程序?
    DOS程序用int 21h的4e和4f号功能;Windows程序用FindFirstFile、FindNextFile。