Header file:
# Include <qdir> # include <qfile> # include <qstring>
Example program:
// Recursively traverse the folder, find all DLL files, and call the registercomfile (qstring dllfilepath) function // scomfilepath: name of the folder to be traversed: int psm_comregister: searchdllfile (const qstring & scomfilepath) {qdir Dir (scomfilepath); If (! Dir. exists () {return-1;} // get all files and file names, but remove them. and .. folder (which is the default one in QT) dir. setfilter (qdir: dirs | qdir: Files | qdir: nodotanddotdot); // folder priority dir. setsorting (qdir: dirsfirst); // convert it into a listqfileinfolist list = dir. entryinfolist (); If (list. size () <1) {return-1;} int I = 0; // do {qfileinfo fileinfo = List. at (I); qstring TT = fileinfo. filename (); // if it is a folder, recursive bool bisdir = fileinfo. isdir (); If (bisdir) {searchdllfile (fileinfo. filepath ();} else {bool isdll = fileinfo. filename (). endswith (". DLL "); If (isdll = true) {registercomfile (fileinfo. filepath () ;}// end elseI ++;} while (I <list. size ());}