| 112 | } |
| 113 | |
| 114 | static HINSTANCE |
| 115 | load(const wchar_t *libraryName, |
| 116 | bool onlySystemDirectory = true) |
| 117 | { |
| 118 | QStringList searchOrder; |
| 119 | |
| 120 | #if !defined(QT_BOOTSTRAPPED) |
| 121 | if (!onlySystemDirectory) { |
| 122 | searchOrder << QFileInfo( QCoreApplication::applicationFilePath() ).path(); |
| 123 | } |
| 124 | #endif |
| 125 | searchOrder << qSystemDirectory(); |
| 126 | |
| 127 | if (!onlySystemDirectory) { |
| 128 | const QString PATH( QLatin1String( qgetenv("PATH").constData() ) ); |
| 129 | # ifdef __NATRON_WIN32__ |
| 130 | const QChar pathSep = QChar::fromLatin1(';'); |
| 131 | # else |
| 132 | // This code is windows-only anyway, but this is here for consistency with other parts of the source |
| 133 | const QChar pathSep = QChar::fromLatin1(':'); |
| 134 | # endif |
| 135 | searchOrder << PATH.split(pathSep, QString::SkipEmptyParts); |
| 136 | } |
| 137 | QString fileName = QString::fromWCharArray(libraryName); |
| 138 | fileName.append( QLatin1String(".dll") ); |
| 139 | |
| 140 | // Start looking in the order specified |
| 141 | Q_FOREACH(const QString &path, searchOrder) { |
| 142 | QString fullPathAttempt = path; |
| 143 | |
| 144 | if ( !fullPathAttempt.endsWith( QLatin1Char('\\') ) ) { |
| 145 | fullPathAttempt.append( QLatin1Char('\\') ); |
| 146 | } |
| 147 | fullPathAttempt.append(fileName); |
| 148 | |
| 149 | std::wstring ws = fullPathAttempt.toStdWString(); |
| 150 | HINSTANCE inst = ::LoadLibraryW( ws.c_str() ); |
| 151 | |
| 152 | if (inst != 0) { |
| 153 | return inst; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | typedef BOOL (WINAPI * GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL); |
| 161 | static GetSpecialFolderPath |
no test coverage detected