C++ (Qt) QString Viewer = ""; QDir AppDir = QDir(qApp->applicationDirPath()); QStringList list; list << "fileview*"; list = AppDir.entryList(list, QDir::Readable|QDir::Files|QDir::Executable); for(int i=0; i<list.count(); i++) { if(list[i] == "fileview" || list[i] == "fileview.exe") { Viewer = AppDir.absoluteFilePath(list[i]); break; } }
C++ (Qt)#ifdef Q_OS_WINextern Q_CORE_EXPORT int qt_ntfs_permission_lookup;#endif ...... QString Viewer = ""; QDir AppDir = QDir(qApp->applicationDirPath()); QStringList list; list << "fileview*";#ifdef Q_OS_WIN qt_ntfs_permission_lookup++;#endif list = AppDir.entryList(list, QDir::Readable|QDir::Files|QDir::Executable);#ifdef Q_OS_WIN qt_ntfs_permission_lookup--;#endif for(int i=0; i<list.count(); i++) { if(list[i] == "fileview" || list[i] == "fileview.exe") { Viewer = AppDir.absoluteFilePath(list[i]); break; } }
QDir obj("D:/123"); QString strList; QStringList Filter; Filter << "*.olp"; foreach(QString str, obj.entryList(Filter, QDir::Files)){ strList = str; strList.replace(QString("olp"), QString("olp9")); if (!obj.rename(str, strList)) cout << "False" << endl; }
foreach(QString str, obj.entryList(QDir::Files))
[b] extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;[/b]
[b] qt_ntfs_permission_lookup++; // turn checking on qt_ntfs_permission_lookup--; // turn it off again[/b]
#ifdef Q_OS_WIN qt_ntfs_permission_lookup++;#endif list = AppDir.entryList(list, QDir::Readable|QDir::Files|QDir::Executable);#ifdef Q_OS_WIN qt_ntfs_permission_lookup--;#endif