资源描述:
《扩展脚本实现你需要的遍历函数功能》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、扩展脚本实现你需要的遍历函数功能lr中没有提供文件遍历函数,但是可以扩展脚本实现你需要的函数功能win32中提供了findfilefirstfindfilenext等api函数,你可以加载api函数实现你要的功能lr中先用lr_load_dll加载包含该api函数的dll,然后直接使用就可以了,下边是lr中提供的一个例子:lr_load_dll("user32.dll");MessageBoxA(NULL,"Thisisthemessagebody","message_caption",0);下边是封装后的函数代码例子,没有经过调试,你把他用dll封装好,然后再lr中调用就可以了!voi
2、dFindFileInDir(char*rootDir,char*strRet){ charfname[MAC_FILENAMELENOPATH]; ZeroMemory(fname,MAC_FILENAMELENOPATH); WIN32_FIND_DATAfd; ZeroMemory(&fd,sizeof(WIN32_FIND_DATA)); HANDLEhSearch; charfilePathName[256]; chartmpPath[256]; ZeroMemory(filePathName,256); ZeroMemory(tmpPath,256); s
3、trcpy(filePathName,rootDir); BOOLbSearchFinished=FALSE; if(filePathName[strlen(filePathName)-1]!='\') { strcat(filePathName,"\"); } strcat(filePathName,"*"); hSearch=FindFirstFile(filePathName,&fd); //Isdirectory if((fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) &&strcmp(fd.cFileN
4、ame,".")&&strcmp(fd.cFileName,"..")) { strcpy(tmpPath,rootDir); strcat(tmpPath,fd.cFileName); FindFileInDir(tmpPath,strRet); } else if(strcmp(fd.cFileName,".")&&strcmp(fd.cFileName,"..")) { sprintf(fname,"%-50.50s",fd.cFileName); strcat(strRet+str
5、Ret[strlen(strRet)],fname); } while(!bSearchFinished) { if(FindNextFile(hSearch,&fd)) { if((fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) &&strcmp(fd.cFileName,".")&&strcmp(fd.cFileName,"..")) { strcpy(tmpPath,rootDir); strcat(tmpPath,
6、fd.cFileName); FindFileInDir(tmpPath,strRet); } else if(strcmp(fd.cFileName,".")&&strcmp(fd.cFileName,"..")) { sprintf(fname,"%-50.50s",fd.cFileName); strcat(strRet+strRet[strlen(strRet)],fname); } } else {
7、 if(GetLastError()==ERROR_NO_MORE_FILES) //NormalFinished { bSearchFinished=TRUE; } else bSearchFinished=TRUE; //TerminateSearch } } FindClose(hSearch); }