Commit 5ae330b6546dabada53c394b53ce9513f552a8a5
- Diff rendering mode:
- inline
- side by side
|   | |||
| 233 | 233 | return QString(); | |
| 234 | 234 | ||
| 235 | 235 | const int wclen_auto = 4096; | |
| 236 | WCHAR wc_auto[wclen_auto]; | ||
| 236 | wchar_t wc_auto[wclen_auto]; | ||
| 237 | 237 | int wclen = wclen_auto; | |
| 238 | WCHAR *wc = wc_auto; | ||
| 238 | wchar_t *wc = wc_auto; | ||
| 239 | 239 | int len; | |
| 240 | 240 | QString sp; | |
| 241 | 241 | bool prepend = false; | |
| … | … | ||
| 275 | 275 | } else { | |
| 276 | 276 | wclen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, | |
| 277 | 277 | mb, mblen, 0, 0); | |
| 278 | wc = new WCHAR[wclen]; | ||
| 278 | wc = new wchar_t[wclen]; | ||
| 279 | 279 | // and try again... | |
| 280 | 280 | } | |
| 281 | 281 | } else if (r == ERROR_NO_UNICODE_TRANSLATION) { | |
| … | … | ||
| 341 | 341 | const char *next = 0; | |
| 342 | 342 | QString s; | |
| 343 | 343 | while((next = CharNextExA(CP_ACP, mb, 0)) != mb) { | |
| 344 | WCHAR wc[2] ={0}; | ||
| 344 | wchar_t wc[2] ={0}; | ||
| 345 | 345 | int charlength = next - mb; | |
| 346 | 346 | int len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS, mb, charlength, wc, 2); | |
| 347 | 347 | if (len>0) { | |
| … | … | ||
| 1042 | 1042 | This might be needed for some applications that want to use their | |
| 1043 | 1043 | own mechanism for setting the locale. | |
| 1044 | 1044 | ||
| 1045 | Setting this codec is not supported on DOS based Windows. | ||
| 1046 | |||
| 1047 | 1045 | \sa codecForLocale() | |
| 1048 | 1046 | */ | |
| 1049 | 1047 | void QTextCodec::setCodecForLocale(QTextCodec *c) | |
| 1050 | 1048 | { | |
| 1051 | #ifdef Q_WS_WIN | ||
| 1052 | if (QSysInfo::WindowsVersion& QSysInfo::WV_DOS_based) | ||
| 1053 | return; | ||
| 1054 | #endif | ||
| 1055 | 1049 | localeMapper = c; | |
| 1056 | 1050 | if (!localeMapper) | |
| 1057 | 1051 | setupLocaleMapper(); |
src/corelib/global/qglobal.cpp
(13 / 30)
|   | |||
| 915 | 915 | \fn bool qt_winUnicode() | |
| 916 | 916 | \relates <QtGlobal> | |
| 917 | 917 | ||
| 918 | Use QSysInfo::WindowsVersion and QSysInfo::WV_DOS_based instead. | ||
| 918 | This function always returns true. | ||
| 919 | 919 | ||
| 920 | 920 | \sa QSysInfo | |
| 921 | 921 | */ | |
| … | … | ||
| 1620 | 1620 | if (winver) | |
| 1621 | 1621 | return winver; | |
| 1622 | 1622 | winver = QSysInfo::WV_NT; | |
| 1623 | #ifndef Q_OS_WINCE | ||
| 1624 | OSVERSIONINFOA osver; | ||
| 1625 | osver.dwOSVersionInfoSize = sizeof(osver); | ||
| 1626 | GetVersionExA(&osver); | ||
| 1627 | #else | ||
| 1628 | DWORD qt_cever = 0; | ||
| 1629 | 1623 | OSVERSIONINFOW osver; | |
| 1630 | 1624 | osver.dwOSVersionInfoSize = sizeof(osver); | |
| 1631 | 1625 | GetVersionEx(&osver); | |
| 1626 | #ifdef Q_OS_WINCE | ||
| 1627 | DWORD qt_cever = 0; | ||
| 1632 | 1628 | qt_cever = osver.dwMajorVersion * 100; | |
| 1633 | 1629 | qt_cever += osver.dwMinorVersion * 10; | |
| 1634 | 1630 | #endif | |
| … | … | ||
| 1900 | 1900 | break; | |
| 1901 | 1901 | default: { | |
| 1902 | 1902 | #ifdef Q_OS_WIN | |
| 1903 | QT_WA({ | ||
| 1904 | unsigned short *string = 0; | ||
| 1905 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, | ||
| 1906 | NULL, | ||
| 1907 | errorCode, | ||
| 1908 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
| 1909 | (LPTSTR)&string, | ||
| 1910 | 0, | ||
| 1911 | NULL); | ||
| 1912 | ret = QString::fromUtf16(string); | ||
| 1913 | LocalFree((HLOCAL)string); | ||
| 1914 | }, { | ||
| 1915 | char *string = 0; | ||
| 1916 | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, | ||
| 1917 | NULL, | ||
| 1918 | errorCode, | ||
| 1919 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
| 1920 | (LPSTR)&string, | ||
| 1921 | 0, | ||
| 1922 | NULL); | ||
| 1923 | ret = QString::fromLocal8Bit(string); | ||
| 1924 | LocalFree((HLOCAL)string); | ||
| 1925 | }); | ||
| 1903 | wchar_t *string = 0; | ||
| 1904 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, | ||
| 1905 | NULL, | ||
| 1906 | errorCode, | ||
| 1907 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
| 1908 | string, | ||
| 1909 | 0, | ||
| 1910 | NULL); | ||
| 1911 | ret = QString::fromWCharArray(string); | ||
| 1912 | LocalFree((HLOCAL)string); | ||
| 1926 | 1913 | ||
| 1927 | 1914 | if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND) | |
| 1928 | 1915 | ret = QString::fromLatin1("The specified module could not be found."); |
src/corelib/global/qglobal.h
(2 / 2)
|   | |||
| 147 | 147 | MSDOS - MS-DOS and Windows | |
| 148 | 148 | OS2 - OS/2 | |
| 149 | 149 | OS2EMX - XFree86 on OS/2 (not PM) | |
| 150 | WIN32 - Win32 (Windows 95/98/ME and Windows NT/2000/XP) | ||
| 150 | WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) | ||
| 151 | 151 | WINCE - WinCE (Windows CE 5.0) | |
| 152 | 152 | CYGWIN - Cygwin | |
| 153 | 153 | SOLARIS - Sun Solaris | |
| … | … | ||
| 1416 | 1416 | ||
| 1417 | 1417 | #if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN) | |
| 1418 | 1418 | #if defined(QT3_SUPPORT) | |
| 1419 | inline QT3_SUPPORT bool qt_winUnicode() { return !(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based); } | ||
| 1419 | inline QT3_SUPPORT bool qt_winUnicode() { return true; } | ||
| 1420 | 1420 | inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; } | |
| 1421 | 1421 | #endif | |
| 1422 | 1422 |
src/corelib/io/qfileinfo.cpp
(1 / 5)
|   | |||
| 117 | 117 | if (access == ExecuteAccess) | |
| 118 | 118 | return getFileFlags(QAbstractFileEngine::ExeUserPerm); | |
| 119 | 119 | ||
| 120 | QT_WA( { | ||
| 121 | return ::_waccess((TCHAR *)QFSFileEnginePrivate::longFileName(data->fileName).utf16(), mode) == 0; | ||
| 122 | } , { | ||
| 123 | return QT_ACCESS(QFSFileEnginePrivate::win95Name(data->fileName), mode) == 0; | ||
| 124 | } ); | ||
| 120 | return ::_waccess((wchar_t*)QFSFileEnginePrivate::longFileName(data->fileName).utf16(), mode) == 0; | ||
| 125 | 121 | #endif | |
| 126 | 122 | return false; | |
| 127 | 123 | } |
|   | |||
| 56 | 56 | QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine() | |
| 57 | 57 | : msg(0) | |
| 58 | 58 | { | |
| 59 | HANDLE h = QT_WA_INLINE(CreateEventW(0, false, false, 0), | ||
| 60 | CreateEventA(0, false, false, 0)); | ||
| 61 | if (h != INVALID_HANDLE_VALUE) { | ||
| 59 | if (HANDLE h = CreateEvent(0, false, false, 0)) { | ||
| 62 | 60 | handles.reserve(MAXIMUM_WAIT_OBJECTS); | |
| 63 | 61 | handles.append(h); | |
| 64 | 62 | } | |
| … | … | ||
| 214 | 214 | const QString effectiveAbsolutePath = | |
| 215 | 215 | isDir ? (absolutePath + QLatin1Char('/')) : absolutePath; | |
| 216 | 216 | ||
| 217 | QT_WA({ | ||
| 218 | handle.handle = FindFirstChangeNotificationW((TCHAR *) QDir::toNativeSeparators(effectiveAbsolutePath).utf16(), | ||
| 219 | false, flags); | ||
| 220 | },{ | ||
| 221 | handle.handle = FindFirstChangeNotificationA(QDir::toNativeSeparators(effectiveAbsolutePath).toLocal8Bit(), | ||
| 222 | false, flags); | ||
| 223 | }) | ||
| 217 | handle.handle = FindFirstChangeNotification((wchar_t*) QDir::toNativeSeparators(effectiveAbsolutePath).utf16(), false, flags); | ||
| 224 | 218 | handle.flags = flags; | |
| 225 | 219 | if (handle.handle == INVALID_HANDLE_VALUE) | |
| 226 | 220 | continue; |
|   | |||
| 79 | 79 | it->currentEntry = uncShares.at(uncShareIndex - 1); | |
| 80 | 80 | } else { | |
| 81 | 81 | // Local directory | |
| 82 | QT_WA({ | ||
| 83 | it->currentEntry = QString::fromUtf16((unsigned short *)findData.cFileName); | ||
| 84 | } , { | ||
| 85 | it->currentEntry = QString::fromLocal8Bit((const char *)findData.cFileName); | ||
| 86 | }); | ||
| 82 | it->currentEntry = QString::fromWCharArray(findData.cFileName); | ||
| 87 | 83 | } | |
| 88 | 84 | } | |
| 89 | 85 | ||
| … | … | ||
| 93 | 93 | if (platform->uncFallback) { | |
| 94 | 94 | ++platform->uncShareIndex; | |
| 95 | 95 | } else if (platform->findFileHandle != INVALID_HANDLE_VALUE) { | |
| 96 | QT_WA({ | ||
| 97 | if (!FindNextFile(platform->findFileHandle, &platform->findData)) { | ||
| 98 | platform->done = true; | ||
| 99 | FindClose(platform->findFileHandle); | ||
| 100 | } | ||
| 101 | } , { | ||
| 102 | if (!FindNextFileA(platform->findFileHandle, (WIN32_FIND_DATAA *)&platform->findData)) { | ||
| 103 | platform->done = true; | ||
| 104 | FindClose(platform->findFileHandle); | ||
| 105 | } | ||
| 106 | }); | ||
| 96 | if (!FindNextFile(platform->findFileHandle, &platform->findData)) { | ||
| 97 | platform->done = true; | ||
| 98 | FindClose(platform->findFileHandle); | ||
| 99 | } | ||
| 107 | 100 | } | |
| 108 | 101 | } | |
| 109 | 102 | ||
| … | … | ||
| 130 | 130 | path.append(QLatin1Char('/')); | |
| 131 | 131 | path.append(QLatin1String("*.*")); | |
| 132 | 132 | ||
| 133 | QT_WA({ | ||
| 134 | QString fileName = QFSFileEnginePrivate::longFileName(path); | ||
| 135 | platform->findFileHandle = FindFirstFileW((TCHAR *)fileName.utf16(), | ||
| 136 | &platform->findData); | ||
| 137 | }, { | ||
| 138 | // Cast is safe, since char is at end of WIN32_FIND_DATA | ||
| 139 | platform->findFileHandle = FindFirstFileA(QFSFileEnginePrivate::win95Name(path), | ||
| 140 | (WIN32_FIND_DATAA*)&platform->findData); | ||
| 141 | }); | ||
| 133 | QString fileName = QFSFileEnginePrivate::longFileName(path); | ||
| 134 | platform->findFileHandle = FindFirstFile((const wchar_t *)fileName.utf16(), &platform->findData); | ||
| 142 | 135 | ||
| 143 | 136 | if (platform->findFileHandle == INVALID_HANDLE_VALUE) { | |
| 144 | 137 | if (path.startsWith(QLatin1String("//"))) { |
|   | |||
| 72 | 72 | ||
| 73 | 73 | public: | |
| 74 | 74 | #ifdef Q_WS_WIN | |
| 75 | static QByteArray win95Name(const QString &path); | ||
| 76 | 75 | static QString longFileName(const QString &path); | |
| 77 | 76 | #endif | |
| 78 | 77 | static QString canonicalized(const QString &path); | |
| … | … | ||
| 150 | 150 | ||
| 151 | 151 | #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) | |
| 152 | 152 | static void resolveLibs(); | |
| 153 | static bool resolveUNCLibs_NT(); | ||
| 154 | static bool resolveUNCLibs_9x(); | ||
| 153 | static bool resolveUNCLibs(); | ||
| 155 | 154 | static bool uncListSharesOnServer(const QString &server, QStringList *list); | |
| 156 | 155 | #endif | |
| 157 | 156 |
src/corelib/io/qfsfileengine_win.cpp
(258 / 538)
|   | |||
| 152 | 152 | ||
| 153 | 153 | triedResolve = true; | |
| 154 | 154 | #if !defined(Q_OS_WINCE) | |
| 155 | if(QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) { | ||
| 156 | HINSTANCE advapiHnd = LoadLibraryW(L"advapi32"); | ||
| 157 | if (advapiHnd) { | ||
| 158 | ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); | ||
| 159 | ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); | ||
| 160 | ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); | ||
| 161 | ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); | ||
| 162 | ptrBuildTrusteeWithNameW = (PtrBuildTrusteeWithNameW)GetProcAddress(advapiHnd, "BuildTrusteeWithNameW"); | ||
| 163 | ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); | ||
| 164 | ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); | ||
| 165 | } | ||
| 166 | if (ptrBuildTrusteeWithNameW) { | ||
| 167 | HINSTANCE versionHnd = LoadLibraryW(L"version"); | ||
| 168 | if (versionHnd) { | ||
| 169 | typedef DWORD (WINAPI *PtrGetFileVersionInfoSizeW)(LPWSTR lptstrFilename,LPDWORD lpdwHandle); | ||
| 170 | PtrGetFileVersionInfoSizeW ptrGetFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)GetProcAddress(versionHnd, "GetFileVersionInfoSizeW"); | ||
| 171 | typedef BOOL (WINAPI *PtrGetFileVersionInfoW)(LPWSTR lptstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData); | ||
| 172 | PtrGetFileVersionInfoW ptrGetFileVersionInfoW = (PtrGetFileVersionInfoW)GetProcAddress(versionHnd, "GetFileVersionInfoW"); | ||
| 173 | typedef BOOL (WINAPI *PtrVerQueryValueW)(const LPVOID pBlock,LPWSTR lpSubBlock,LPVOID *lplpBuffer,PUINT puLen); | ||
| 174 | PtrVerQueryValueW ptrVerQueryValueW = (PtrVerQueryValueW)GetProcAddress(versionHnd, "VerQueryValueW"); | ||
| 175 | if(ptrGetFileVersionInfoSizeW && ptrGetFileVersionInfoW && ptrVerQueryValueW) { | ||
| 176 | DWORD fakeHandle; | ||
| 177 | DWORD versionSize = ptrGetFileVersionInfoSizeW(L"secur32.dll", &fakeHandle); | ||
| 178 | if(versionSize) { | ||
| 179 | LPVOID versionData; | ||
| 180 | versionData = malloc(versionSize); | ||
| 181 | if(ptrGetFileVersionInfoW(L"secur32.dll", 0, versionSize, versionData)) { | ||
| 182 | UINT puLen; | ||
| 183 | VS_FIXEDFILEINFO *pLocalInfo; | ||
| 184 | if(ptrVerQueryValueW(versionData, L"\\", (void**)&pLocalInfo, &puLen)) { | ||
| 185 | WORD wVer1, wVer2, wVer3, wVer4; | ||
| 186 | wVer1 = HIWORD(pLocalInfo->dwFileVersionMS); | ||
| 187 | wVer2 = LOWORD(pLocalInfo->dwFileVersionMS); | ||
| 188 | wVer3 = HIWORD(pLocalInfo->dwFileVersionLS); | ||
| 189 | wVer4 = LOWORD(pLocalInfo->dwFileVersionLS); | ||
| 190 | // It will not work with secur32.dll version 5.0.2195.2862 | ||
| 191 | if(!(wVer1 == 5 && wVer2 == 0 && wVer3 == 2195 && (wVer4 == 2862 || wVer4 == 4587))) { | ||
| 192 | HINSTANCE userHnd = LoadLibraryW(L"secur32"); | ||
| 193 | if (userHnd) { | ||
| 194 | typedef BOOL (WINAPI *PtrGetUserNameExW)(EXTENDED_NAME_FORMAT nameFormat, ushort* lpBuffer, LPDWORD nSize); | ||
| 195 | PtrGetUserNameExW ptrGetUserNameExW = (PtrGetUserNameExW)GetProcAddress(userHnd, "GetUserNameExW"); | ||
| 196 | if(ptrGetUserNameExW) { | ||
| 197 | static TCHAR buffer[258]; | ||
| 198 | DWORD bufferSize = 257; | ||
| 199 | ptrGetUserNameExW(NameSamCompatible, (ushort*)buffer, &bufferSize); | ||
| 200 | ptrBuildTrusteeWithNameW(¤tUserTrusteeW, (ushort*)buffer); | ||
| 201 | } | ||
| 202 | FreeLibrary(userHnd); | ||
| 155 | HINSTANCE advapiHnd = LoadLibraryW(L"advapi32"); | ||
| 156 | if (advapiHnd) { | ||
| 157 | ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); | ||
| 158 | ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); | ||
| 159 | ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); | ||
| 160 | ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); | ||
| 161 | ptrBuildTrusteeWithNameW = (PtrBuildTrusteeWithNameW)GetProcAddress(advapiHnd, "BuildTrusteeWithNameW"); | ||
| 162 | ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); | ||
| 163 | ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); | ||
| 164 | } | ||
| 165 | if (ptrBuildTrusteeWithNameW) { | ||
| 166 | HINSTANCE versionHnd = LoadLibraryW(L"version"); | ||
| 167 | if (versionHnd) { | ||
| 168 | typedef DWORD (WINAPI *PtrGetFileVersionInfoSizeW)(LPWSTR lptstrFilename,LPDWORD lpdwHandle); | ||
| 169 | PtrGetFileVersionInfoSizeW ptrGetFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)GetProcAddress(versionHnd, "GetFileVersionInfoSizeW"); | ||
| 170 | typedef BOOL (WINAPI *PtrGetFileVersionInfoW)(LPWSTR lptstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData); | ||
| 171 | PtrGetFileVersionInfoW ptrGetFileVersionInfoW = (PtrGetFileVersionInfoW)GetProcAddress(versionHnd, "GetFileVersionInfoW"); | ||
| 172 | typedef BOOL (WINAPI *PtrVerQueryValueW)(const LPVOID pBlock,LPWSTR lpSubBlock,LPVOID *lplpBuffer,PUINT puLen); | ||
| 173 | PtrVerQueryValueW ptrVerQueryValueW = (PtrVerQueryValueW)GetProcAddress(versionHnd, "VerQueryValueW"); | ||
| 174 | if(ptrGetFileVersionInfoSizeW && ptrGetFileVersionInfoW && ptrVerQueryValueW) { | ||
| 175 | DWORD fakeHandle; | ||
| 176 | DWORD versionSize = ptrGetFileVersionInfoSizeW(L"secur32.dll", &fakeHandle); | ||
| 177 | if(versionSize) { | ||
| 178 | LPVOID versionData; | ||
| 179 | versionData = malloc(versionSize); | ||
| 180 | if(ptrGetFileVersionInfoW(L"secur32.dll", 0, versionSize, versionData)) { | ||
| 181 | UINT puLen; | ||
| 182 | VS_FIXEDFILEINFO *pLocalInfo; | ||
| 183 | if(ptrVerQueryValueW(versionData, L"\\", (void**)&pLocalInfo, &puLen)) { | ||
| 184 | WORD wVer1, wVer2, wVer3, wVer4; | ||
| 185 | wVer1 = HIWORD(pLocalInfo->dwFileVersionMS); | ||
| 186 | wVer2 = LOWORD(pLocalInfo->dwFileVersionMS); | ||
| 187 | wVer3 = HIWORD(pLocalInfo->dwFileVersionLS); | ||
| 188 | wVer4 = LOWORD(pLocalInfo->dwFileVersionLS); | ||
| 189 | // It will not work with secur32.dll version 5.0.2195.2862 | ||
| 190 | if(!(wVer1 == 5 && wVer2 == 0 && wVer3 == 2195 && (wVer4 == 2862 || wVer4 == 4587))) { | ||
| 191 | HINSTANCE userHnd = LoadLibraryW(L"secur32"); | ||
| 192 | if (userHnd) { | ||
| 193 | typedef BOOL (WINAPI *PtrGetUserNameExW)(EXTENDED_NAME_FORMAT nameFormat, ushort* lpBuffer, LPDWORD nSize); | ||
| 194 | PtrGetUserNameExW ptrGetUserNameExW = (PtrGetUserNameExW)GetProcAddress(userHnd, "GetUserNameExW"); | ||
| 195 | if(ptrGetUserNameExW) { | ||
| 196 | static wchar_t buffer[258]; | ||
| 197 | DWORD bufferSize = 257; | ||
| 198 | ptrGetUserNameExW(NameSamCompatible, (ushort*)buffer, &bufferSize); | ||
| 199 | ptrBuildTrusteeWithNameW(¤tUserTrusteeW, (ushort*)buffer); | ||
| 203 | 200 | } | |
| 201 | FreeLibrary(userHnd); | ||
| 204 | 202 | } | |
| 205 | 203 | } | |
| 206 | 204 | } | |
| 207 | free(versionData); | ||
| 208 | 205 | } | |
| 206 | free(versionData); | ||
| 209 | 207 | } | |
| 210 | FreeLibrary(versionHnd); | ||
| 211 | 208 | } | |
| 209 | FreeLibrary(versionHnd); | ||
| 212 | 210 | } | |
| 213 | 211 | ptrOpenProcessToken = (PtrOpenProcessToken)GetProcAddress(advapiHnd, "OpenProcessToken"); | |
| 214 | HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); | ||
| 212 | HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); | ||
| 215 | 213 | if (userenvHnd) { | |
| 216 | 214 | ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); | |
| 217 | 215 | } | |
| … | … | ||
| 223 | 223 | #endif // QT_NO_LIBRARY | |
| 224 | 224 | ||
| 225 | 225 | // UNC functions NT | |
| 226 | typedef DWORD (WINAPI *PtrNetShareEnum_NT)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); | ||
| 227 | static PtrNetShareEnum_NT ptrNetShareEnum_NT = 0; | ||
| 228 | typedef DWORD (WINAPI *PtrNetApiBufferFree_NT)(LPVOID); | ||
| 229 | static PtrNetApiBufferFree_NT ptrNetApiBufferFree_NT = 0; | ||
| 230 | typedef struct _SHARE_INFO_1_NT { | ||
| 226 | typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); | ||
| 227 | static PtrNetShareEnum ptrNetShareEnum = 0; | ||
| 228 | typedef DWORD (WINAPI *PtrNetApiBufferFree)(LPVOID); | ||
| 229 | static PtrNetApiBufferFree ptrNetApiBufferFree = 0; | ||
| 230 | typedef struct _SHARE_INFO_1 { | ||
| 231 | 231 | LPWSTR shi1_netname; | |
| 232 | 232 | DWORD shi1_type; | |
| 233 | 233 | LPWSTR shi1_remark; | |
| 234 | } SHARE_INFO_1_NT; | ||
| 234 | } SHARE_INFO_1; | ||
| 235 | 235 | ||
| 236 | 236 | ||
| 237 | bool QFSFileEnginePrivate::resolveUNCLibs_NT() | ||
| 237 | bool QFSFileEnginePrivate::resolveUNCLibs() | ||
| 238 | 238 | { | |
| 239 | 239 | static bool triedResolve = false; | |
| 240 | 240 | if (!triedResolve) { | |
| 241 | 241 | #ifndef QT_NO_THREAD | |
| 242 | 242 | QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); | |
| 243 | 243 | if (triedResolve) { | |
| 244 | return ptrNetShareEnum_NT && ptrNetApiBufferFree_NT; | ||
| 244 | return ptrNetShareEnum && ptrNetApiBufferFree; | ||
| 245 | 245 | } | |
| 246 | 246 | #endif | |
| 247 | 247 | triedResolve = true; | |
| 248 | 248 | #if !defined(Q_OS_WINCE) | |
| 249 | 249 | HINSTANCE hLib = LoadLibraryW(L"Netapi32"); | |
| 250 | 250 | if (hLib) { | |
| 251 | ptrNetShareEnum_NT = (PtrNetShareEnum_NT)GetProcAddress(hLib, "NetShareEnum"); | ||
| 252 | if (ptrNetShareEnum_NT) | ||
| 253 | ptrNetApiBufferFree_NT = (PtrNetApiBufferFree_NT)GetProcAddress(hLib, "NetApiBufferFree"); | ||
| 251 | ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum"); | ||
| 252 | if (ptrNetShareEnum) | ||
| 253 | ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree"); | ||
| 254 | 254 | } | |
| 255 | 255 | #endif | |
| 256 | 256 | } | |
| 257 | return ptrNetShareEnum_NT && ptrNetApiBufferFree_NT; | ||
| 257 | return ptrNetShareEnum && ptrNetApiBufferFree; | ||
| 258 | 258 | } | |
| 259 | 259 | ||
| 260 | // UNC functions 9x | ||
| 261 | typedef DWORD (WINAPI *PtrNetShareEnum_9x)(const char FAR *, short, char FAR *, unsigned short, unsigned short FAR *, unsigned short FAR *); | ||
| 262 | static PtrNetShareEnum_9x ptrNetShareEnum_9x = 0; | ||
| 263 | #ifdef LM20_NNLEN | ||
| 264 | # define LM20_NNLEN_9x LM20_NNLEN | ||
| 265 | #else | ||
| 266 | # define LM20_NNLEN_9x 12 | ||
| 267 | #endif | ||
| 268 | typedef struct _SHARE_INFO_1_9x { | ||
| 269 | char shi1_netname[LM20_NNLEN_9x+1]; | ||
| 270 | char shi1_pad1; | ||
| 271 | unsigned short shi1_type; | ||
| 272 | char FAR* shi1_remark; | ||
| 273 | } SHARE_INFO_1_9x; | ||
| 274 | |||
| 275 | bool QFSFileEnginePrivate::resolveUNCLibs_9x() | ||
| 276 | { | ||
| 277 | static bool triedResolve = false; | ||
| 278 | if (!triedResolve) { | ||
| 279 | #ifndef QT_NO_THREAD | ||
| 280 | QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); | ||
| 281 | if (triedResolve) { | ||
| 282 | return ptrNetShareEnum_9x; | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | triedResolve = true; | ||
| 286 | #if !defined(Q_OS_WINCE) | ||
| 287 | HINSTANCE hLib = LoadLibraryA("Svrapi"); | ||
| 288 | if (hLib) | ||
| 289 | ptrNetShareEnum_9x = (PtrNetShareEnum_9x)GetProcAddress(hLib, "NetShareEnum"); | ||
| 290 | #endif | ||
| 291 | } | ||
| 292 | return ptrNetShareEnum_9x; | ||
| 293 | } | ||
| 294 | |||
| 295 | 260 | bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringList *list) | |
| 296 | 261 | { | |
| 297 | if (resolveUNCLibs_NT()) { | ||
| 298 | SHARE_INFO_1_NT *BufPtr, *p; | ||
| 262 | if (resolveUNCLibs()) { | ||
| 263 | SHARE_INFO_1 *BufPtr, *p; | ||
| 299 | 264 | DWORD res; | |
| 300 | 265 | DWORD er=0,tr=0,resume=0, i; | |
| 301 | 266 | do { | |
| 302 | res = ptrNetShareEnum_NT((wchar_t*)server.utf16(), 1, (LPBYTE *)&BufPtr, DWORD(-1), &er, &tr, &resume); | ||
| 267 | res = ptrNetShareEnum((wchar_t*)server.utf16(), 1, (LPBYTE *)&BufPtr, DWORD(-1), &er, &tr, &resume); | ||
| 303 | 268 | if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA) { | |
| 304 | 269 | p=BufPtr; | |
| 305 | 270 | for (i = 1; i <= er; ++i) { | |
| 306 | 271 | if (list && p->shi1_type == 0) | |
| 307 | list->append(QString::fromUtf16((unsigned short *)p->shi1_netname)); | ||
| 272 | list->append(QString::fromWCharArray(p->shi1_netname)); | ||
| 308 | 273 | p++; | |
| 309 | 274 | } | |
| 310 | 275 | } | |
| 311 | ptrNetApiBufferFree_NT(BufPtr); | ||
| 276 | ptrNetApiBufferFree(BufPtr); | ||
| 312 | 277 | } while (res==ERROR_MORE_DATA); | |
| 313 | 278 | return res == ERROR_SUCCESS; | |
| 314 | 279 | ||
| 315 | } else if (resolveUNCLibs_9x()) { | ||
| 316 | SHARE_INFO_1_9x *pBuf = 0; | ||
| 317 | short cbBuffer; | ||
| 318 | unsigned short nEntriesRead = 0; | ||
| 319 | unsigned short nTotalEntries = 0; | ||
| 320 | short numBuffs = 20; | ||
| 321 | DWORD nStatus = 0; | ||
| 322 | do { | ||
| 323 | cbBuffer = numBuffs * sizeof(SHARE_INFO_1_9x); | ||
| 324 | pBuf = (SHARE_INFO_1_9x *)malloc(cbBuffer); | ||
| 325 | if (pBuf) { | ||
| 326 | nStatus = ptrNetShareEnum_9x(server.toLocal8Bit().constData(), 1, (char FAR *)pBuf, cbBuffer, &nEntriesRead, &nTotalEntries); | ||
| 327 | if ((nStatus == ERROR_SUCCESS)) { | ||
| 328 | for (int i = 0; i < nEntriesRead; ++i) { | ||
| 329 | if (list && pBuf[i].shi1_type == 0) | ||
| 330 | list->append(QString::fromLocal8Bit(pBuf[i].shi1_netname)); | ||
| 331 | } | ||
| 332 | free(pBuf); | ||
| 333 | break; | ||
| 334 | } | ||
| 335 | free(pBuf); | ||
| 336 | numBuffs *=2; | ||
| 337 | } | ||
| 338 | } while (nStatus == ERROR_MORE_DATA); | ||
| 339 | return nStatus == ERROR_SUCCESS; | ||
| 340 | 280 | } | |
| 341 | 281 | return false; | |
| 342 | 282 | } | |
| … | … | ||
| 337 | 337 | return false; | |
| 338 | 338 | } | |
| 339 | 339 | ||
| 340 | #if !defined(Q_OS_WINCE) | ||
| 341 | // If you change this function, remember to also change the UNICODE version | ||
| 342 | static QString nativeAbsoluteFilePathA(const QString &path) | ||
| 340 | static QString nativeAbsoluteFilePathCore(const QString &path) | ||
| 343 | 341 | { | |
| 344 | 342 | QString ret; | |
| 345 | QVarLengthArray<char, MAX_PATH> buf(MAX_PATH); | ||
| 346 | char *fileName = 0; | ||
| 347 | QByteArray ba = path.toLocal8Bit(); | ||
| 348 | DWORD retLen = GetFullPathNameA(ba.constData(), buf.size(), buf.data(), &fileName); | ||
| 349 | if (retLen > (DWORD)buf.size()) { | ||
| 350 | buf.resize(retLen); | ||
| 351 | retLen = GetFullPathNameA(ba.constData(), buf.size(), buf.data(), &fileName); | ||
| 352 | } | ||
| 353 | if (retLen != 0) | ||
| 354 | ret = QString::fromLocal8Bit(buf.data(), retLen); | ||
| 355 | return ret; | ||
| 356 | } | ||
| 357 | #endif | ||
| 358 | |||
| 359 | // If you change this function, remember to also change the NON-UNICODE version | ||
| 360 | static QString nativeAbsoluteFilePathW(const QString &path) | ||
| 361 | { | ||
| 362 | QString ret; | ||
| 363 | 343 | #if !defined(Q_OS_WINCE) | |
| 364 | 344 | QVarLengthArray<wchar_t, MAX_PATH> buf(MAX_PATH); | |
| 365 | 345 | wchar_t *fileName = 0; | |
| 366 | DWORD retLen = GetFullPathNameW((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); | ||
| 346 | DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); | ||
| 367 | 347 | if (retLen > (DWORD)buf.size()) { | |
| 368 | 348 | buf.resize(retLen); | |
| 369 | retLen = GetFullPathNameW((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); | ||
| 349 | retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); | ||
| 370 | 350 | } | |
| 371 | 351 | if (retLen != 0) | |
| 372 | ret = QString::fromUtf16((unsigned short *)buf.data(), retLen); | ||
| 352 | ret = QString::fromWCharArray(buf.data(), retLen); | ||
| 373 | 353 | #else | |
| 374 | 354 | if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\'))) | |
| 375 | 355 | ret = QDir::toNativeSeparators(path); | |
| … | … | ||
| 361 | 361 | ||
| 362 | 362 | static QString nativeAbsoluteFilePath(const QString &path) | |
| 363 | 363 | { | |
| 364 | QString absPath = QT_WA_INLINE(nativeAbsoluteFilePathW(path), nativeAbsoluteFilePathA(path)); | ||
| 364 | QString absPath = nativeAbsoluteFilePathCore(path); | ||
| 365 | 365 | // This is really ugly, but GetFullPathName strips off whitespace at the end. | |
| 366 | 366 | // If you for instance write ". " in the lineedit of QFileDialog, | |
| 367 | 367 | // (which is an invalid filename) this function will strip the space off and viola, | |
| … | … | ||
| 379 | 379 | return absPath; | |
| 380 | 380 | } | |
| 381 | 381 | ||
| 382 | QByteArray QFSFileEnginePrivate::win95Name(const QString &path) | ||
| 383 | { | ||
| 384 | QString ret(path); | ||
| 385 | if(path.length() > 1 && path[0] == QLatin1Char('/') && path[1] == QLatin1Char('/')) { | ||
| 386 | // Win95 cannot handle slash-slash needs slosh-slosh. | ||
| 387 | ret[0] = QLatin1Char('\\'); | ||
| 388 | ret[1] = QLatin1Char('\\'); | ||
| 389 | int n = ret.indexOf(QLatin1Char('/')); | ||
| 390 | if(n >= 0) | ||
| 391 | ret[n] = QLatin1Char('\\'); | ||
| 392 | } else if(path.length() > 3 && path[2] == QLatin1Char('/') && path[3] == QLatin1Char('/')) { | ||
| 393 | ret[2] = QLatin1Char('\\'); | ||
| 394 | ret.remove(3, 1); | ||
| 395 | int n = ret.indexOf(QLatin1Char('/')); | ||
| 396 | if(n >= 0) | ||
| 397 | ret[n] = QLatin1Char('\\'); | ||
| 398 | } | ||
| 399 | return ret.toLocal8Bit(); | ||
| 400 | } | ||
| 401 | |||
| 402 | 382 | /*! | |
| 403 | 383 | \internal | |
| 404 | 384 | */ | |
| … | … | ||
| 405 | 405 | */ | |
| 406 | 406 | void QFSFileEnginePrivate::nativeInitFileName() | |
| 407 | 407 | { | |
| 408 | QT_WA({ | ||
| 409 | QString path = longFileName(QDir::toNativeSeparators(fixIfRelativeUncPath(filePath))); | ||
| 410 | nativeFilePath = QByteArray((const char *)path.utf16(), path.size() * 2 + 1); | ||
| 411 | }, { | ||
| 412 | QString path = fixIfRelativeUncPath(filePath); | ||
| 413 | nativeFilePath = win95Name(path).replace('/', '\\'); | ||
| 414 | }); | ||
| 408 | QString path = longFileName(QDir::toNativeSeparators(fixIfRelativeUncPath(filePath))); | ||
| 409 | nativeFilePath = QByteArray((const char *)path.utf16(), path.size() * 2 + 1); | ||
| 415 | 410 | } | |
| 416 | 411 | ||
| 417 | 412 | /* | |
| … | … | ||
| 432 | 432 | ? OPEN_ALWAYS : OPEN_EXISTING; | |
| 433 | 433 | ||
| 434 | 434 | // Create the file handle. | |
| 435 | QT_WA({ | ||
| 436 | fileHandle = CreateFileW((TCHAR *)nativeFilePath.constData(), | ||
| 437 | accessRights, | ||
| 438 | shareMode, | ||
| 439 | &securityAtts, | ||
| 440 | creationDisp, | ||
| 441 | FILE_ATTRIBUTE_NORMAL, | ||
| 442 | NULL); | ||
| 443 | }, { | ||
| 444 | fileHandle = CreateFileA(nativeFilePath.constData(), | ||
| 445 | accessRights, | ||
| 446 | shareMode, | ||
| 447 | &securityAtts, | ||
| 448 | creationDisp, | ||
| 449 | FILE_ATTRIBUTE_NORMAL, | ||
| 450 | NULL); | ||
| 451 | }); | ||
| 435 | fileHandle = CreateFile((const wchar_t*)nativeFilePath.constData(), | ||
| 436 | accessRights, | ||
| 437 | shareMode, | ||
| 438 | &securityAtts, | ||
| 439 | creationDisp, | ||
| 440 | FILE_ATTRIBUTE_NORMAL, | ||
| 441 | NULL); | ||
| 452 | 442 | ||
| 453 | 443 | // Bail out on error. | |
| 454 | 444 | if (fileHandle == INVALID_HANDLE_VALUE) { | |
| … | … | ||
| 524 | 524 | // Not-open mode, where the file name is known: We'll check the | |
| 525 | 525 | // file system directly. | |
| 526 | 526 | if (openMode == QIODevice::NotOpen && !nativeFilePath.isEmpty()) { | |
| 527 | bool ok = false; | ||
| 528 | 527 | WIN32_FILE_ATTRIBUTE_DATA attribData; | |
| 529 | QT_WA({ | ||
| 530 | ok = ::GetFileAttributesExW((TCHAR *)nativeFilePath.constData(), | ||
| 528 | bool ok = ::GetFileAttributesEx((const wchar_t*)nativeFilePath.constData(), | ||
| 531 | 529 | GetFileExInfoStandard, &attribData); | |
| 532 | } , { | ||
| 533 | ok = ::GetFileAttributesExA(nativeFilePath.constData(), | ||
| 534 | GetFileExInfoStandard, &attribData); | ||
| 535 | }); | ||
| 536 | 530 | if (ok) { | |
| 537 | 531 | qint64 size = attribData.nFileSizeHigh; | |
| 538 | 532 | size <<= 32; | |
| … | … | ||
| 826 | 826 | bool QFSFileEngine::remove() | |
| 827 | 827 | { | |
| 828 | 828 | Q_D(QFSFileEngine); | |
| 829 | QT_WA({ | ||
| 830 | return ::DeleteFileW((TCHAR*)QFSFileEnginePrivate::longFileName(d->filePath).utf16()) != 0; | ||
| 831 | } , { | ||
| 832 | return ::DeleteFileA(QFSFileEnginePrivate::win95Name(d->filePath)) != 0; | ||
| 833 | }); | ||
| 829 | return ::DeleteFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16()) != 0; | ||
| 834 | 830 | } | |
| 835 | 831 | ||
| 836 | 832 | bool QFSFileEngine::copy(const QString ©Name) | |
| 837 | 833 | { | |
| 838 | 834 | Q_D(QFSFileEngine); | |
| 839 | QT_WA({ | ||
| 840 | return ::CopyFileW((TCHAR*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), | ||
| 841 | (TCHAR*)QFSFileEnginePrivate::longFileName(copyName).utf16(), true) != 0; | ||
| 842 | } , { | ||
| 843 | return ::CopyFileA(QFSFileEnginePrivate::win95Name(d->filePath), | ||
| 844 | QFSFileEnginePrivate::win95Name(copyName), true) != 0; | ||
| 845 | }); | ||
| 835 | return ::CopyFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), | ||
| 836 | (wchar_t*)QFSFileEnginePrivate::longFileName(copyName).utf16(), true) != 0; | ||
| 846 | 837 | } | |
| 847 | 838 | ||
| 848 | 839 | bool QFSFileEngine::rename(const QString &newName) | |
| 849 | 840 | { | |
| 850 | 841 | Q_D(QFSFileEngine); | |
| 851 | QT_WA({ | ||
| 852 | return ::MoveFileW((TCHAR*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), | ||
| 853 | (TCHAR*)QFSFileEnginePrivate::longFileName(newName).utf16()) != 0; | ||
| 854 | } , { | ||
| 855 | return ::MoveFileA(QFSFileEnginePrivate::win95Name(d->filePath), | ||
| 856 | QFSFileEnginePrivate::win95Name(newName)) != 0; | ||
| 857 | }); | ||
| 842 | return ::MoveFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), | ||
| 843 | (wchar_t*)QFSFileEnginePrivate::longFileName(newName).utf16()) != 0; | ||
| 858 | 844 | } | |
| 859 | 845 | ||
| 860 | 846 | static inline bool mkDir(const QString &path) | |
| … | … | ||
| 864 | 864 | if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256) | |
| 865 | 865 | return false; | |
| 866 | 866 | #endif | |
| 867 | QT_WA({ | ||
| 868 | return ::CreateDirectoryW((TCHAR*)QFSFileEnginePrivate::longFileName(path).utf16(), 0); | ||
| 869 | } , { | ||
| 870 | return ::CreateDirectoryA(QFSFileEnginePrivate::win95Name(QFileInfo(path).absoluteFilePath()), 0); | ||
| 871 | }); | ||
| 867 | return ::CreateDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), 0); | ||
| 872 | 868 | } | |
| 873 | 869 | ||
| 874 | 870 | static inline bool rmDir(const QString &path) | |
| 875 | 871 | { | |
| 876 | QT_WA({ | ||
| 877 | return ::RemoveDirectoryW((TCHAR*)QFSFileEnginePrivate::longFileName(path).utf16()); | ||
| 878 | } , { | ||
| 879 | return ::RemoveDirectoryA(QFSFileEnginePrivate::win95Name(QFileInfo(path).absoluteFilePath())); | ||
| 880 | }); | ||
| 872 | return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); | ||
| 881 | 873 | } | |
| 882 | 874 | ||
| 883 | 875 | static inline bool isDirPath(const QString &dirPath, bool *existed) | |
| … | … | ||
| 878 | 878 | if (path.length() == 2 &&path.at(1) == QLatin1Char(':')) | |
| 879 | 879 | path += QLatin1Char('\\'); | |
| 880 | 880 | ||
| 881 | DWORD fileAttrib = INVALID_FILE_ATTRIBUTES; | ||
| 882 | QT_WA({ | ||
| 883 | fileAttrib = ::GetFileAttributesW((TCHAR*)QFSFileEnginePrivate::longFileName(path).utf16()); | ||
| 884 | } , { | ||
| 885 | fileAttrib = ::GetFileAttributesA(QFSFileEnginePrivate::win95Name(QFileInfo(path).absoluteFilePath())); | ||
| 886 | }); | ||
| 881 | DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); | ||
| 887 | 882 | ||
| 888 | 883 | if (existed) | |
| 889 | 884 | *existed = fileAttrib != INVALID_FILE_ATTRIBUTES; | |
| … | … | ||
| 960 | 960 | return false; | |
| 961 | 961 | ||
| 962 | 962 | #if !defined(Q_OS_WINCE) | |
| 963 | int r; | ||
| 964 | QT_WA({ | ||
| 965 | r = ::SetCurrentDirectoryW((WCHAR*)path.utf16()); | ||
| 966 | } , { | ||
| 967 | r = ::SetCurrentDirectoryA(QFSFileEnginePrivate::win95Name(path)); | ||
| 968 | }); | ||
| 969 | return r != 0; | ||
| 963 | return ::SetCurrentDirectory((wchar_t*)path.utf16()) != 0; | ||
| 970 | 964 | #else | |
| 971 | qfsPrivateCurrentDir = QFSFileEnginePrivate::longFileName(path); | ||
| 972 | return true; | ||
| 965 | qfsPrivateCurrentDir = QFSFileEnginePrivate::longFileName(path); | ||
| 966 | return true; | ||
| 973 | 967 | #endif | |
| 974 | 968 | } | |
| 975 | 969 | ||
| … | … | ||
| 976 | 976 | fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':')) { | |
| 977 | 977 | int drv = fileName.toUpper().at(0).toLatin1() - 'A' + 1; | |
| 978 | 978 | if (_getdrive() != drv) { | |
| 979 | QT_WA({ | ||
| 980 | TCHAR buf[PATH_MAX]; | ||
| 981 | ::_wgetdcwd(drv, buf, PATH_MAX); | ||
| 982 | ret.setUtf16((ushort*)buf, uint(::wcslen(buf))); | ||
| 983 | }, { | ||
| 984 | char buf[PATH_MAX]; | ||
| 985 | ::_getdcwd(drv, buf, PATH_MAX); | ||
| 986 | ret = QString::fromLatin1(buf); | ||
| 987 | }); | ||
| 979 | wchar_t buf[PATH_MAX]; | ||
| 980 | ::_wgetdcwd(drv, buf, PATH_MAX); | ||
| 981 | ret = QString::fromWCharArray(buf); | ||
| 988 | 982 | } | |
| 989 | 983 | } | |
| 990 | 984 | if (ret.isEmpty()) { | |
| 991 | 985 | //just the pwd | |
| 992 | QT_WA({ | ||
| 993 | DWORD size = 0; | ||
| 994 | WCHAR currentName[PATH_MAX]; | ||
| 995 | size = ::GetCurrentDirectoryW(PATH_MAX, currentName); | ||
| 996 | if (size !=0) { | ||
| 997 | if (size > PATH_MAX) { | ||
| 998 | WCHAR * newCurrentName = new WCHAR[size]; | ||
| 999 | if (::GetCurrentDirectoryW(PATH_MAX, newCurrentName) != 0) | ||
| 1000 | ret = QString::fromUtf16((ushort*)newCurrentName); | ||
| 1001 | delete [] newCurrentName; | ||
| 1002 | } else { | ||
| 1003 | ret = QString::fromUtf16((ushort*)currentName); | ||
| 1004 | } | ||
| 986 | DWORD size = 0; | ||
| 987 | wchar_t currentName[PATH_MAX]; | ||
| 988 | size = ::GetCurrentDirectory(PATH_MAX, currentName); | ||
| 989 | if (size != 0) { | ||
| 990 | if (size > PATH_MAX) { | ||
| 991 | wchar_t *newCurrentName = new wchar_t[size]; | ||
| 992 | if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0) | ||
| 993 | ret = QString::fromWCharArray(newCurrentName); | ||
| 994 | delete [] newCurrentName; | ||
| 995 | } else { | ||
| 996 | ret = QString::fromWCharArray(currentName); | ||
| 1005 | 997 | } | |
| 1006 | } , { | ||
| 1007 | DWORD size = 0; | ||
| 1008 | char currentName[PATH_MAX]; | ||
| 1009 | size = ::GetCurrentDirectoryA(PATH_MAX, currentName); | ||
| 1010 | if (size !=0) | ||
| 1011 | ret = QString::fromLocal8Bit(currentName); | ||
| 1012 | }); | ||
| 998 | } | ||
| 1013 | 999 | } | |
| 1014 | 1000 | if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) | |
| 1015 | 1001 | ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. | |
| 1016 | 1002 | return QDir::fromNativeSeparators(ret); | |
| 1017 | 1003 | #else | |
| 1018 | Q_UNUSED(fileName); | ||
| 1019 | if (qfsPrivateCurrentDir.isEmpty()) | ||
| 1020 | qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); | ||
| 1004 | Q_UNUSED(fileName); | ||
| 1005 | if (qfsPrivateCurrentDir.isEmpty()) | ||
| 1006 | qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); | ||
| 1021 | 1007 | ||
| 1022 | 1008 | return QDir::fromNativeSeparators(qfsPrivateCurrentDir); | |
| 1023 | 1009 | #endif | |
| … | … | ||
| 1013 | 1013 | { | |
| 1014 | 1014 | QString ret; | |
| 1015 | 1015 | #if !defined(QT_NO_LIBRARY) | |
| 1016 | QT_WA ( | ||
| 1017 | { | ||
| 1018 | QFSFileEnginePrivate::resolveLibs(); | ||
| 1019 | if (ptrOpenProcessToken && ptrGetUserProfileDirectoryW) { | ||
| 1020 | HANDLE hnd = ::GetCurrentProcess(); | ||
| 1021 | HANDLE token = 0; | ||
| 1022 | BOOL ok = ::ptrOpenProcessToken(hnd, TOKEN_QUERY, &token); | ||
| 1023 | if (ok) { | ||
| 1024 | DWORD dwBufferSize = 0; | ||
| 1025 | // First call, to determine size of the strings (with '\0'). | ||
| 1026 | ok = ::ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize); | ||
| 1027 | if (!ok && dwBufferSize != 0) { // We got the required buffer size | ||
| 1028 | wchar_t *userDirectory = new wchar_t[dwBufferSize]; | ||
| 1029 | // Second call, now we can fill the allocated buffer. | ||
| 1030 | ok = ::ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize); | ||
| 1031 | if (ok) | ||
| 1032 | ret = QString::fromUtf16((ushort*)userDirectory); | ||
| 1016 | QFSFileEnginePrivate::resolveLibs(); | ||
| 1017 | if (ptrOpenProcessToken && ptrGetUserProfileDirectoryW) { | ||
| 1018 | HANDLE hnd = ::GetCurrentProcess(); | ||
| 1019 | HANDLE token = 0; | ||
| 1020 | BOOL ok = ::ptrOpenProcessToken(hnd, TOKEN_QUERY, &token); | ||
| 1021 | if (ok) { | ||
| 1022 | DWORD dwBufferSize = 0; | ||
| 1023 | // First call, to determine size of the strings (with '\0'). | ||
| 1024 | ok = ::ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize); | ||
| 1025 | if (!ok && dwBufferSize != 0) { // We got the required buffer size | ||
| 1026 | wchar_t *userDirectory = new wchar_t[dwBufferSize]; | ||
| 1027 | // Second call, now we can fill the allocated buffer. | ||
| 1028 | ok = ::ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize); | ||
| 1029 | if (ok) | ||
| 1030 | ret = QString::fromWCharArray(userDirectory); | ||
| 1033 | 1031 | ||
| 1034 | delete [] userDirectory; | ||
| 1035 | } | ||
| 1036 | ::CloseHandle(token); | ||
| 1037 | } | ||
| 1038 | } | ||
| 1039 | } | ||
| 1040 | , | ||
| 1041 | { | ||
| 1042 | // GetUserProfileDirectory is only available from NT 4.0, | ||
| 1043 | // so fall through for Win98 and friends version. | ||
| 1044 | }) | ||
| 1032 | delete [] userDirectory; | ||
| 1033 | } | ||
| 1034 | ::CloseHandle(token); | ||
| 1035 | } | ||
| 1036 | } | ||
| 1045 | 1037 | #endif | |
| 1046 | 1038 | if(ret.isEmpty() || !QFile::exists(ret)) { | |
| 1047 | 1039 | ret = QString::fromLocal8Bit(qgetenv("USERPROFILE").constData()); | |
| … | … | ||
| 1073 | 1073 | ||
| 1074 | 1074 | QString QFSFileEngine::tempPath() | |
| 1075 | 1075 | { | |
| 1076 | QString ret; | ||
| 1077 | int success; | ||
| 1078 | QT_WA({ | ||
| 1079 | wchar_t tempPath[MAX_PATH]; | ||
| 1080 | success = GetTempPathW(MAX_PATH, tempPath); | ||
| 1081 | ret = QString::fromUtf16((ushort*)tempPath); | ||
| 1082 | } , { | ||
| 1083 | char tempPath[MAX_PATH]; | ||
| 1084 | success = GetTempPathA(MAX_PATH, tempPath); | ||
| 1085 | ret = QString::fromLocal8Bit(tempPath); | ||
| 1086 | }); | ||
| 1076 | wchar_t tempPath[MAX_PATH]; | ||
| 1077 | int success = GetTempPath(MAX_PATH, tempPath); | ||
| 1078 | QString ret = QString::fromWCharArray(tempPath); | ||
| 1079 | |||
| 1087 | 1080 | if (ret.isEmpty() || !success) { | |
| 1088 | 1081 | #if !defined(Q_OS_WINCE) | |
| 1089 | 1082 | ret = QString::fromLatin1("c:/tmp"); | |
| … | … | ||
| 1100 | 1100 | #elif defined(Q_OS_OS2EMX) | |
| 1101 | 1101 | quint32 driveBits, cur; | |
| 1102 | 1102 | if(DosQueryCurrentDisk(&cur,&driveBits) != NO_ERROR) | |
| 1103 | exit(1); | ||
| 1103 | exit(1); | ||
| 1104 | 1104 | driveBits &= 0x3ffffff; | |
| 1105 | 1105 | #endif | |
| 1106 | 1106 | char driveName[] = "A:/"; | |
| … | … | ||
| 1142 | 1142 | } | |
| 1143 | 1143 | } | |
| 1144 | 1144 | #else | |
| 1145 | DWORD tmpAttributes = GetFileAttributesW((TCHAR*)QFSFileEnginePrivate::longFileName(fname).utf16()); | ||
| 1145 | DWORD tmpAttributes = GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(fname).utf16()); | ||
| 1146 | 1146 | if (tmpAttributes != -1) { | |
| 1147 | 1147 | fileAttrib = tmpAttributes; | |
| 1148 | 1148 | could_stat = true; | |
| 1149 | 1149 | } | |
| 1150 | 1150 | #endif | |
| 1151 | 1151 | } else { | |
| 1152 | QT_WA({ | ||
| 1153 | fileAttrib = GetFileAttributesW((TCHAR*)QFSFileEnginePrivate::longFileName(fname).utf16()); | ||
| 1154 | } , { | ||
| 1155 | fileAttrib = GetFileAttributesA(QFSFileEnginePrivate::win95Name(QFileInfo(fname).absoluteFilePath())); | ||
| 1156 | }); | ||
| 1152 | fileAttrib = GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(fname).utf16()); | ||
| 1157 | 1153 | could_stat = fileAttrib != INVALID_FILE_ATTRIBUTES; | |
| 1158 | 1154 | if (!could_stat) { | |
| 1159 | 1155 | #if !defined(Q_OS_WINCE) | |
| … | … | ||
| 1209 | 1209 | #if !defined(Q_OS_WINCE) | |
| 1210 | 1210 | #if !defined(QT_NO_LIBRARY) | |
| 1211 | 1211 | QString ret; | |
| 1212 | QT_WA({ | ||
| 1213 | bool neededCoInit = false; | ||
| 1214 | IShellLink *psl; // pointer to IShellLink i/f | ||
| 1215 | HRESULT hres; | ||
| 1216 | WIN32_FIND_DATA wfd; | ||
| 1217 | TCHAR szGotPath[MAX_PATH]; | ||
| 1218 | // Get pointer to the IShellLink interface. | ||
| 1219 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | ||
| 1220 | IID_IShellLink, (LPVOID *)&psl); | ||
| 1221 | 1212 | ||
| 1222 | if(hres == CO_E_NOTINITIALIZED) { // COM was not initialized | ||
| 1223 | neededCoInit = true; | ||
| 1224 | CoInitialize(NULL); | ||
| 1225 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | ||
| 1226 | IID_IShellLink, (LPVOID *)&psl); | ||
| 1227 | } | ||
| 1228 | if(SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface. | ||
| 1229 | IPersistFile *ppf; | ||
| 1230 | hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf); | ||
| 1231 | if(SUCCEEDED(hres)) { | ||
| 1232 | hres = ppf->Load((LPOLESTR)link.utf16(), STGM_READ); | ||
| 1233 | //The original path of the link is retrieved. If the file/folder | ||
| 1234 | //was moved, the return value still have the old path. | ||
| 1235 | if(SUCCEEDED(hres)) { | ||
| 1236 | if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR) | ||
| 1237 | ret = QString::fromUtf16((ushort*)szGotPath); | ||
| 1238 | } | ||
| 1239 | ppf->Release(); | ||
| 1240 | } | ||
| 1241 | psl->Release(); | ||
| 1242 | } | ||
| 1243 | if(neededCoInit) | ||
| 1244 | CoUninitialize(); | ||
| 1245 | } , { | ||
| 1246 | bool neededCoInit = false; | ||
| 1247 | IShellLinkA *psl; // pointer to IShellLink i/f | ||
| 1248 | HRESULT hres; | ||
| 1249 | WIN32_FIND_DATAA wfd; | ||
| 1250 | char szGotPath[MAX_PATH]; | ||
| 1251 | // Get pointer to the IShellLink interface. | ||
| 1213 | bool neededCoInit = false; | ||
| 1214 | IShellLink *psl; // pointer to IShellLink i/f | ||
| 1215 | WIN32_FIND_DATA wfd; | ||
| 1216 | wchar_t szGotPath[MAX_PATH]; | ||
| 1252 | 1217 | ||
| 1253 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | ||
| 1254 | IID_IShellLinkA, (LPVOID *)&psl); | ||
| 1218 | // Get pointer to the IShellLink interface. | ||
| 1219 | HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl); | ||
| 1255 | 1220 | ||
| 1256 | if(hres == CO_E_NOTINITIALIZED) { // COM was not initialized | ||
| 1257 | neededCoInit = true; | ||
| 1258 | CoInitialize(NULL); | ||
| 1259 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | ||
| 1260 | IID_IShellLinkA, (LPVOID *)&psl); | ||
| 1261 | } | ||
| 1262 | if(SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface. | ||
| 1263 | IPersistFile *ppf; | ||
| 1264 | hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf); | ||
| 1265 | if(SUCCEEDED(hres)) { | ||
| 1266 | hres = ppf->Load((LPOLESTR)QFileInfo(link).absoluteFilePath().utf16(), STGM_READ); | ||
| 1267 | //The original path of the link is retrieved. If the file/folder | ||
| 1268 | //was moved, the return value still have the old path. | ||
| 1269 | if(SUCCEEDED(hres)) { | ||
| 1270 | if (psl->GetPath((char*)szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR) | ||
| 1271 | ret = QString::fromLocal8Bit(szGotPath); | ||
| 1272 | } | ||
| 1273 | ppf->Release(); | ||
| 1221 | if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized | ||
| 1222 | neededCoInit = true; | ||
| 1223 | CoInitialize(NULL); | ||
| 1224 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | ||
| 1225 | IID_IShellLink, (LPVOID *)&psl); | ||
| 1226 | } | ||
| 1227 | if (SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface. | ||
| 1228 | IPersistFile *ppf; | ||
| 1229 | hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf); | ||
| 1230 | if(SUCCEEDED(hres)) { | ||
| 1231 | hres = ppf->Load((LPOLESTR)link.utf16(), STGM_READ); | ||
| 1232 | //The original path of the link is retrieved. If the file/folder | ||
| 1233 | //was moved, the return value still have the old path. | ||
| 1234 | if(SUCCEEDED(hres)) { | ||
| 1235 | if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR) | ||
| 1236 | ret = QString::fromWCharArray(szGotPath); | ||
| 1274 | 1237 | } | |
| 1275 | psl->Release(); | ||
| 1238 | ppf->Release(); | ||
| 1276 | 1239 | } | |
| 1277 | if(neededCoInit) | ||
| 1278 | CoUninitialize(); | ||
| 1279 | }); | ||
| 1240 | psl->Release(); | ||
| 1241 | } | ||
| 1242 | if (neededCoInit) | ||
| 1243 | CoUninitialize(); | ||
| 1244 | |||
| 1280 | 1245 | return ret; | |
| 1281 | 1246 | #else | |
| 1282 | 1247 | Q_UNUSED(link); | |
| … | … | ||
| 1251 | 1251 | wchar_t target[MAX_PATH]; | |
| 1252 | 1252 | QString result; | |
| 1253 | 1253 | if (SHGetShortcutTarget((wchar_t*)QFileInfo(link).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) { | |
| 1254 | result = QString::fromUtf16(reinterpret_cast<const ushort *> (target)); | ||
| 1254 | result = QString::fromWCharArray(target); | ||
| 1255 | 1255 | if (result.startsWith(QLatin1Char('"'))) | |
| 1256 | 1256 | result.remove(0,1); | |
| 1257 | 1257 | if (result.endsWith(QLatin1Char('"'))) | |
| … | … | ||
| 1278 | 1278 | QString linkName = newName; | |
| 1279 | 1279 | //### assume that they add .lnk | |
| 1280 | 1280 | ||
| 1281 | QT_WA({ | ||
| 1282 | HRESULT hres; | ||
| 1283 | IShellLink *psl; | ||
| 1284 | bool neededCoInit = false; | ||
| 1281 | IShellLink *psl; | ||
| 1282 | bool neededCoInit = false; | ||
| 1285 | 1283 | ||
| 1286 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); | ||
| 1287 | if(hres == CO_E_NOTINITIALIZED) { // COM was not initialized | ||
| 1288 | neededCoInit = true; | ||
| 1289 | CoInitialize(NULL); | ||
| 1290 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); | ||
| 1291 | } | ||
| 1292 | if (SUCCEEDED(hres)) { | ||
| 1293 | hres = psl->SetPath((wchar_t *)fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\')).utf16()); | ||
| 1294 | if (SUCCEEDED(hres)) { | ||
| 1295 | hres = psl->SetWorkingDirectory((wchar_t *)fileName(AbsolutePathName).replace(QLatin1Char('/'), QLatin1Char('\\')).utf16()); | ||
| 1296 | if (SUCCEEDED(hres)) { | ||
| 1297 | IPersistFile *ppf; | ||
| 1298 | hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf); | ||
| 1299 | if (SUCCEEDED(hres)) { | ||
| 1300 | hres = ppf->Save((TCHAR*)linkName.utf16(), TRUE); | ||
| 1301 | if (SUCCEEDED(hres)) | ||
| 1302 | ret = true; | ||
| 1303 | ppf->Release(); | ||
| 1304 | } | ||
| 1305 | } | ||
| 1306 | } | ||
| 1307 | psl->Release(); | ||
| 1308 | } | ||
| 1309 | if(neededCoInit) | ||
| 1310 | CoUninitialize(); | ||
| 1311 | } , { | ||
| 1312 | // the SetPath() call _sometimes_ changes the current path and when it does it sometimes | ||
| 1313 | // does not let us change it back unless we call currentPath() many times. | ||
| 1314 | QString cwd = currentPath(); | ||
| 1315 | HRESULT hres; | ||
| 1316 | IShellLinkA *psl; | ||
| 1317 | bool neededCoInit = false; | ||
| 1284 | HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); | ||
| 1318 | 1285 | ||
| 1286 | if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized | ||
| 1287 | neededCoInit = true; | ||
| 1288 | CoInitialize(NULL); | ||
| 1319 | 1289 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); | |
| 1320 | if(hres == CO_E_NOTINITIALIZED) { // COM was not initialized | ||
| 1321 | neededCoInit = true; | ||
| 1322 | CoInitialize(NULL); | ||
| 1323 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); | ||
| 1324 | } | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | if (SUCCEEDED(hres)) { | ||
| 1293 | hres = psl->SetPath((wchar_t *)fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\')).utf16()); | ||
| 1325 | 1294 | if (SUCCEEDED(hres)) { | |
| 1326 | currentPath(); | ||
| 1327 | hres = psl->SetPath((char *)QString::fromLocal8Bit(QFSFileEnginePrivate::win95Name(fileName(AbsoluteName))).utf16()); | ||
| 1328 | currentPath(); | ||
| 1295 | hres = psl->SetWorkingDirectory((wchar_t *)fileName(AbsolutePathName).replace(QLatin1Char('/'), QLatin1Char('\\')).utf16()); | ||
| 1329 | 1296 | if (SUCCEEDED(hres)) { | |
| 1330 | hres = psl->SetWorkingDirectory((char *)QString::fromLocal8Bit(QFSFileEnginePrivate::win95Name(fileName(AbsolutePathName))).utf16()); | ||
| 1331 | currentPath(); | ||
| 1297 | IPersistFile *ppf; | ||
| 1298 | hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf); | ||
| 1332 | 1299 | if (SUCCEEDED(hres)) { | |
| 1333 | IPersistFile *ppf; | ||
| 1334 | hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf); | ||
| 1335 | if (SUCCEEDED(hres)) { | ||
| 1336 | currentPath(); | ||
| 1337 | hres = ppf->Save((LPCOLESTR)linkName.utf16(), TRUE); | ||
| 1338 | currentPath(); | ||
| 1339 | if (SUCCEEDED(hres)) | ||
| 1340 | ret = true; | ||
| 1341 | ppf->Release(); | ||
| 1342 | } | ||
| 1300 | hres = ppf->Save((wchar_t*)linkName.utf16(), TRUE); | ||
| 1301 | if (SUCCEEDED(hres)) | ||
| 1302 | ret = true; | ||
| 1303 | ppf->Release(); | ||
| 1343 | 1304 | } | |
| 1344 | psl->Release(); | ||
| 1345 | 1305 | } | |
| 1346 | 1306 | } | |
| 1347 | if(neededCoInit) | ||
| 1307 | psl->Release(); | ||
| 1308 | } | ||
| 1309 | if(neededCoInit) | ||
| 1348 | 1310 | CoUninitialize(); | |
| 1349 | setCurrentPath(cwd); | ||
| 1350 | }); | ||
| 1311 | |||
| 1351 | 1312 | return ret; | |
| 1352 | 1313 | #else | |
| 1353 | 1314 | Q_UNUSED(newName); | |
| … | … | ||
| 1335 | 1335 | ||
| 1336 | 1336 | #if !defined(QT_NO_LIBRARY) | |
| 1337 | 1337 | if((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { | |
| 1338 | PSID pOwner = 0; | ||
| 1339 | PSID pGroup = 0; | ||
| 1340 | PACL pDacl; | ||
| 1338 | PSID pOwner = 0; | ||
| 1339 | PSID pGroup = 0; | ||
| 1340 | PACL pDacl; | ||
| 1341 | 1341 | PSECURITY_DESCRIPTOR pSD; | |
| 1342 | 1342 | ACCESS_MASK access_mask; | |
| 1343 | 1343 | ||
| … | … | ||
| 1347 | 1347 | ||
| 1348 | 1348 | QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath; | |
| 1349 | 1349 | DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT, | |
| 1350 | OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, | ||
| 1351 | &pOwner, &pGroup, &pDacl, 0, &pSD); | ||
| 1350 | OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, | ||
| 1351 | &pOwner, &pGroup, &pDacl, 0, &pSD); | ||
| 1352 | 1352 | ||
| 1353 | 1353 | if(res == ERROR_SUCCESS) { | |
| 1354 | 1354 | TRUSTEE_W trustee; | |
| 1355 | 1355 | { //user | |
| 1356 | 1356 | if(ptrGetEffectiveRightsFromAclW(pDacl, ¤tUserTrusteeW, &access_mask) != ERROR_SUCCESS) | |
| 1357 | 1357 | access_mask = (ACCESS_MASK)-1; | |
| 1358 | if(access_mask & ReadMask) | ||
| 1359 | ret |= QAbstractFileEngine::ReadUserPerm; | ||
| 1360 | if(access_mask & WriteMask) | ||
| 1361 | ret |= QAbstractFileEngine::WriteUserPerm; | ||
| 1362 | if(access_mask & ExecMask) | ||
| 1363 | ret |= QAbstractFileEngine::ExeUserPerm; | ||
| 1358 | if(access_mask & ReadMask) | ||
| 1359 | ret |= QAbstractFileEngine::ReadUserPerm; | ||
| 1360 | if(access_mask & WriteMask) | ||
| 1361 | ret |= QAbstractFileEngine::WriteUserPerm; | ||
| 1362 | if(access_mask & ExecMask) | ||
| 1363 | ret |= QAbstractFileEngine::ExeUserPerm; | ||
| 1364 | 1364 | } | |
| 1365 | 1365 | { //owner | |
| 1366 | 1366 | ptrBuildTrusteeWithSidW(&trustee, pOwner); | |
| 1367 | 1367 | if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) | |
| 1368 | 1368 | access_mask = (ACCESS_MASK)-1; | |
| 1369 | if(access_mask & ReadMask) | ||
| 1370 | ret |= QAbstractFileEngine::ReadOwnerPerm; | ||
| 1371 | if(access_mask & WriteMask) | ||
| 1372 | ret |= QAbstractFileEngine::WriteOwnerPerm; | ||
| 1373 | if(access_mask & ExecMask) | ||
| 1374 | ret |= QAbstractFileEngine::ExeOwnerPerm; | ||
| 1369 | if(access_mask & ReadMask) | ||
| 1370 | ret |= QAbstractFileEngine::ReadOwnerPerm; | ||
| 1371 | if(access_mask & WriteMask) | ||
| 1372 | ret |= QAbstractFileEngine::WriteOwnerPerm; | ||
| 1373 | if(access_mask & ExecMask) | ||
| 1374 | ret |= QAbstractFileEngine::ExeOwnerPerm; | ||
| 1375 | 1375 | } | |
| 1376 | 1376 | { //group | |
| 1377 | 1377 | ptrBuildTrusteeWithSidW(&trustee, pGroup); | |
| 1378 | 1378 | if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) | |
| 1379 | 1379 | access_mask = (ACCESS_MASK)-1; | |
| 1380 | if(access_mask & ReadMask) | ||
| 1381 | ret |= QAbstractFileEngine::ReadGroupPerm; | ||
| 1382 | if(access_mask & WriteMask) | ||
| 1383 | ret |= QAbstractFileEngine::WriteGroupPerm; | ||
| 1384 | if(access_mask & ExecMask) | ||
| 1385 | ret |= QAbstractFileEngine::ExeGroupPerm; | ||
| 1380 | if(access_mask & ReadMask) | ||
| 1381 | ret |= QAbstractFileEngine::ReadGroupPerm; | ||
| 1382 | if(access_mask & WriteMask) | ||
| 1383 | ret |= QAbstractFileEngine::WriteGroupPerm; | ||
| 1384 | if(access_mask & ExecMask) | ||
| 1385 | ret |= QAbstractFileEngine::ExeGroupPerm; | ||
| 1386 | 1386 | } | |
| 1387 | 1387 | { //other (world) | |
| 1388 | 1388 | // Create SID for Everyone (World) | |
| … | … | ||
| 1392 | 1392 | ptrBuildTrusteeWithSidW(&trustee, pWorld); | |
| 1393 | 1393 | if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) | |
| 1394 | 1394 | access_mask = (ACCESS_MASK)-1; // ### | |
| 1395 | if(access_mask & ReadMask) | ||
| 1396 | ret |= QAbstractFileEngine::ReadOtherPerm; | ||
| 1397 | if(access_mask & WriteMask) | ||
| 1398 | ret |= QAbstractFileEngine::WriteOtherPerm; | ||
| 1399 | if(access_mask & ExecMask) | ||
| 1400 | ret |= QAbstractFileEngine::ExeOtherPerm; | ||
| 1395 | if(access_mask & ReadMask) | ||
| 1396 | ret |= QAbstractFileEngine::ReadOtherPerm; | ||
| 1397 | if(access_mask & WriteMask) | ||
| 1398 | ret |= QAbstractFileEngine::WriteOtherPerm; | ||
| 1399 | if(access_mask & ExecMask) | ||
| 1400 | ret |= QAbstractFileEngine::ExeOtherPerm; | ||
| 1401 | 1401 | } | |
| 1402 | 1402 | ptrFreeSid(pWorld); | |
| 1403 | 1403 | } | |
| … | … | ||
| 1407 | 1407 | } else | |
| 1408 | 1408 | #endif | |
| 1409 | 1409 | { | |
| 1410 | //### what to do with permissions if we don't use ntfs or are not on a NT system | ||
| 1411 | // for now just add all permissions and what about exe missions ?? | ||
| 1412 | // also qt_ntfs_permission_lookup is now not set by defualt ... should it ? | ||
| 1413 | ret |= QAbstractFileEngine::ReadOtherPerm | QAbstractFileEngine::ReadGroupPerm | ||
| 1414 | | QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadUserPerm | ||
| 1415 | | QAbstractFileEngine::WriteUserPerm | QAbstractFileEngine::WriteOwnerPerm | ||
| 1416 | | QAbstractFileEngine::WriteGroupPerm | QAbstractFileEngine::WriteOtherPerm; | ||
| 1410 | //### what to do with permissions if we don't use NTFS | ||
| 1411 | // for now just add all permissions and what about exe missions ?? | ||
| 1412 | // also qt_ntfs_permission_lookup is now not set by defualt ... should it ? | ||
| 1413 | ret |= QAbstractFileEngine::ReadOtherPerm | QAbstractFileEngine::ReadGroupPerm | ||
| 1414 | | QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadUserPerm | ||
| 1415 | | QAbstractFileEngine::WriteUserPerm | QAbstractFileEngine::WriteOwnerPerm | ||
| 1416 | | QAbstractFileEngine::WriteGroupPerm | QAbstractFileEngine::WriteOtherPerm; | ||
| 1417 | 1417 | } | |
| 1418 | 1418 | ||
| 1419 | 1419 | if (doStat()) { | |
| … | … | ||
| 1648 | 1648 | return false; | |
| 1649 | 1649 | ||
| 1650 | 1650 | #if !defined(Q_OS_WINCE) | |
| 1651 | QT_WA({ | ||
| 1652 | ret = ::_wchmod((TCHAR*)d->filePath.utf16(), mode) == 0; | ||
| 1653 | } , { | ||
| 1654 | ret = ::_chmod(d->filePath.toLocal8Bit(), mode) == 0; | ||
| 1655 | }); | ||
| 1651 | ret = ::_wchmod((wchar_t*)d->filePath.utf16(), mode) == 0; | ||
| 1656 | 1652 | #else | |
| 1657 | ret = ::_wchmod((TCHAR*)d->longFileName(d->filePath).utf16(), mode); | ||
| 1653 | ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode); | ||
| 1658 | 1654 | #endif | |
| 1659 | 1655 | return ret; | |
| 1660 | 1656 | } | |
| … | … | ||
| 1693 | 1693 | static inline QDateTime fileTimeToQDateTime(const FILETIME *time) | |
| 1694 | 1694 | { | |
| 1695 | 1695 | QDateTime ret; | |
| 1696 | if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based || QSysInfo::WindowsVersion & QSysInfo::WV_CE_based) { | ||
| 1697 | // SystemTimeToTzSpecificLocalTime is not available on Win98/ME so we have to pull it off ourselves. | ||
| 1698 | SYSTEMTIME systime; | ||
| 1699 | FILETIME ftime; | ||
| 1700 | systime.wYear = 1970; | ||
| 1701 | systime.wMonth = 1; | ||
| 1702 | systime.wDay = 1; | ||
| 1703 | systime.wHour = 0; | ||
| 1704 | systime.wMinute = 0; | ||
| 1705 | systime.wSecond = 0; | ||
| 1706 | systime.wMilliseconds = 0; | ||
| 1707 | systime.wDayOfWeek = 4; | ||
| 1708 | SystemTimeToFileTime(&systime, &ftime); | ||
| 1709 | unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime; | ||
| 1710 | FileTimeToSystemTime(time, &systime); | ||
| 1711 | unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime; | ||
| 1712 | unsigned __int64 difftime = acttime - time1970; | ||
| 1713 | difftime /= 10000000; | ||
| 1714 | ret.setTime_t((unsigned int)difftime); | ||
| 1715 | } else { | ||
| 1716 | #ifndef Q_OS_WINCE | ||
| 1717 | SYSTEMTIME sTime, lTime; | ||
| 1718 | FileTimeToSystemTime(time, &sTime); | ||
| 1719 | SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime); | ||
| 1720 | ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay)); | ||
| 1721 | ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds)); | ||
| 1696 | |||
| 1697 | #if defined(Q_OS_WINCE) | ||
| 1698 | SYSTEMTIME systime; | ||
| 1699 | FILETIME ftime; | ||
| 1700 | systime.wYear = 1970; | ||
| 1701 | systime.wMonth = 1; | ||
| 1702 | systime.wDay = 1; | ||
| 1703 | systime.wHour = 0; | ||
| 1704 | systime.wMinute = 0; | ||
| 1705 | systime.wSecond = 0; | ||
| 1706 | systime.wMilliseconds = 0; | ||
| 1707 | systime.wDayOfWeek = 4; | ||
| 1708 | SystemTimeToFileTime(&systime, &ftime); | ||
| 1709 | unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime; | ||
| 1710 | FileTimeToSystemTime(time, &systime); | ||
| 1711 | unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime; | ||
| 1712 | unsigned __int64 difftime = acttime - time1970; | ||
| 1713 | difftime /= 10000000; | ||
| 1714 | ret.setTime_t((unsigned int)difftime); | ||
| 1715 | #else | ||
| 1716 | SYSTEMTIME sTime, lTime; | ||
| 1717 | FileTimeToSystemTime(time, &sTime); | ||
| 1718 | SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime); | ||
| 1719 | ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay)); | ||
| 1720 | ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds)); | ||
| 1722 | 1721 | #endif | |
| 1723 | } | ||
| 1722 | |||
| 1724 | 1723 | return ret; | |
| 1725 | 1724 | } | |
| 1726 | 1725 | ||
| … | … | ||
| 1743 | 1743 | } | |
| 1744 | 1744 | #endif | |
| 1745 | 1745 | } else { | |
| 1746 | bool ok = false; | ||
| 1747 | 1746 | WIN32_FILE_ATTRIBUTE_DATA attribData; | |
| 1748 | QT_WA({ | ||
| 1749 | ok = ::GetFileAttributesExW((TCHAR*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), GetFileExInfoStandard, &attribData); | ||
| 1750 | } , { | ||
| 1751 | ok = ::GetFileAttributesExA(QFSFileEnginePrivate::win95Name(QFileInfo(d->filePath).absoluteFilePath()), GetFileExInfoStandard, &attribData); | ||
| 1752 | }); | ||
| 1747 | bool ok = ::GetFileAttributesEx((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), GetFileExInfoStandard, &attribData); | ||
| 1753 | 1748 | if (ok) { | |
| 1754 | 1749 | if(time == CreationTime) | |
| 1755 | 1750 | ret = fileTimeToQDateTime(&attribData.ftCreationTime); | |
| … | … | ||
| 1764 | 1764 | Q_UNUSED(flags); | |
| 1765 | 1765 | if (openMode == QFile::NotOpen) { | |
| 1766 | 1766 | q->setError(QFile::PermissionsError, qt_error_string()); | |
| 1767 | return 0; | ||
| 1767 | return 0; | ||
| 1768 | 1768 | } | |
| 1769 | 1769 | if (offset == 0 && size == 0) { | |
| 1770 | 1770 | q->setError(QFile::UnspecifiedError, qt_error_string()); | |
| 1771 | return 0; | ||
| 1771 | return 0; | ||
| 1772 | 1772 | } | |
| 1773 | 1773 | ||
| 1774 | 1774 | ||
| … | … | ||
| 1781 | 1781 | #ifdef Q_USE_DEPRECATED_MAP_API | |
| 1782 | 1782 | nativeClose(); | |
| 1783 | 1783 | if (fileMapHandle == INVALID_HANDLE_VALUE) { | |
| 1784 | fileMapHandle = CreateFileForMappingW((TCHAR *)nativeFilePath.constData(), | ||
| 1784 | fileMapHandle = CreateFileForMapping((const wchar_t*)nativeFilePath.constData(), | ||
| 1785 | 1785 | GENERIC_READ | (openMode & QIODevice::WriteOnly ? GENERIC_WRITE : 0), | |
| 1786 | 1786 | 0, | |
| 1787 | 1787 | NULL, | |
| … | … | ||
| 1796 | 1796 | #endif | |
| 1797 | 1797 | ||
| 1798 | 1798 | // first create the file mapping handle | |
| 1799 | HANDLE mapHandle = 0; | ||
| 1800 | 1799 | DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; | |
| 1801 | QT_WA({ | ||
| 1802 | mapHandle = ::CreateFileMappingW(handle, 0, protection, | ||
| 1803 | 0, 0, 0); | ||
| 1804 | },{ | ||
| 1805 | mapHandle = ::CreateFileMappingA(handle, 0, protection, | ||
| 1806 | 0, 0, 0); | ||
| 1807 | }); | ||
| 1800 | HANDLE mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); | ||
| 1808 | 1801 | if (mapHandle == NULL) { | |
| 1809 | 1802 | q->setError(QFile::PermissionsError, qt_error_string()); | |
| 1810 | 1803 | #ifdef Q_USE_DEPRECATED_MAP_API | |
| 1811 | 1804 | mapHandleClose(); | |
| 1812 | 1805 | #endif | |
| 1813 | return 0; | ||
| 1806 | return 0; | ||
| 1814 | 1807 | } | |
| 1815 | 1808 | ||
| 1816 | 1809 | // setup args to map | |
| … | … | ||
| 1832 | 1832 | switch(GetLastError()) { | |
| 1833 | 1833 | case ERROR_ACCESS_DENIED: | |
| 1834 | 1834 | q->setError(QFile::PermissionsError, qt_error_string()); | |
| 1835 | break; | ||
| 1835 | break; | ||
| 1836 | 1836 | case ERROR_INVALID_PARAMETER: | |
| 1837 | 1837 | // size are out of bounds | |
| 1838 | 1838 | default: |
src/corelib/io/qprocess_win.cpp
(64 / 151)
|   | |||
| 54 | 54 | #include <private/qthread_p.h> | |
| 55 | 55 | #include <qdebug.h> | |
| 56 | 56 | ||
| 57 | #include "private/qfsfileengine_p.h" // for longFileName and win95FileName | ||
| 57 | #include "private/qfsfileengine_p.h" // for longFileName | ||
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | 60 | #ifndef QT_NO_PROCESS | |
| … | … | ||
| 122 | 122 | if (&channel == &stdinChannel) { | |
| 123 | 123 | // try to open in read-only mode | |
| 124 | 124 | channel.pipe[1] = INVALID_Q_PIPE; | |
| 125 | QT_WA({ | ||
| 126 | channel.pipe[0] = | ||
| 127 | CreateFileW((TCHAR*)QFSFileEnginePrivate::longFileName(channel.file).utf16(), | ||
| 128 | GENERIC_READ, | ||
| 129 | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 130 | &secAtt, | ||
| 131 | OPEN_EXISTING, | ||
| 132 | FILE_ATTRIBUTE_NORMAL, | ||
| 133 | NULL); | ||
| 134 | }, { | ||
| 135 | channel.pipe[0] = | ||
| 136 | CreateFileA(QFSFileEnginePrivate::win95Name(channel.file), | ||
| 137 | GENERIC_READ, | ||
| 138 | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 139 | &secAtt, | ||
| 140 | OPEN_EXISTING, | ||
| 141 | FILE_ATTRIBUTE_NORMAL, | ||
| 142 | NULL); | ||
| 143 | }); | ||
| 125 | channel.pipe[0] = | ||
| 126 | CreateFile((const wchar_t*)QFSFileEnginePrivate::longFileName(channel.file).utf16(), | ||
| 127 | GENERIC_READ, | ||
| 128 | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 129 | &secAtt, | ||
| 130 | OPEN_EXISTING, | ||
| 131 | FILE_ATTRIBUTE_NORMAL, | ||
| 132 | NULL); | ||
| 133 | |||
| 144 | 134 | if (channel.pipe[0] != INVALID_Q_PIPE) | |
| 145 | 135 | return true; | |
| 146 | 136 | ||
| … | … | ||
| 138 | 138 | } else { | |
| 139 | 139 | // open in write mode | |
| 140 | 140 | channel.pipe[0] = INVALID_Q_PIPE; | |
| 141 | DWORD creation; | ||
| 142 | if (channel.append) | ||
| 143 | creation = OPEN_ALWAYS; | ||
| 144 | else | ||
| 145 | creation = CREATE_ALWAYS; | ||
| 141 | channel.pipe[1] = | ||
| 142 | CreateFile((const wchar_t *)QFSFileEnginePrivate::longFileName(channel.file).utf16(), | ||
| 143 | GENERIC_WRITE, | ||
| 144 | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 145 | &secAtt, | ||
| 146 | channel.append ? OPEN_ALWAYS : CREATE_ALWAYS, | ||
| 147 | FILE_ATTRIBUTE_NORMAL, | ||
| 148 | NULL); | ||
| 146 | 149 | ||
| 147 | QT_WA({ | ||
| 148 | channel.pipe[1] = | ||
| 149 | CreateFileW((TCHAR*)QFSFileEnginePrivate::longFileName(channel.file).utf16(), | ||
| 150 | GENERIC_WRITE, | ||
| 151 | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 152 | &secAtt, | ||
| 153 | creation, | ||
| 154 | FILE_ATTRIBUTE_NORMAL, | ||
| 155 | NULL); | ||
| 156 | }, { | ||
| 157 | channel.pipe[1] = | ||
| 158 | CreateFileA(QFSFileEnginePrivate::win95Name(channel.file), | ||
| 159 | GENERIC_WRITE, | ||
| 160 | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
| 161 | &secAtt, | ||
| 162 | creation, | ||
| 163 | FILE_ATTRIBUTE_NORMAL, | ||
| 164 | NULL); | ||
| 165 | }); | ||
| 166 | 150 | if (channel.pipe[1] != INVALID_Q_PIPE) { | |
| 167 | 151 | if (channel.append) { | |
| 168 | 152 | SetFilePointer(channel.pipe[1], 0, NULL, FILE_END); | |
| … | … | ||
| 301 | 301 | int pos = 0; | |
| 302 | 302 | QHash<QString, QString>::ConstIterator it = copy.constBegin(), | |
| 303 | 303 | end = copy.constEnd(); | |
| 304 | #ifdef UNICODE | ||
| 305 | if (!(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)) { | ||
| 306 | static const TCHAR equal = L'='; | ||
| 307 | static const TCHAR nul = L'\0'; | ||
| 308 | 304 | ||
| 309 | for ( ; it != end; ++it) { | ||
| 310 | uint tmpSize = sizeof(TCHAR) * (it.key().length() + it.value().length() + 2); | ||
| 311 | // ignore empty strings | ||
| 312 | if (tmpSize == sizeof(TCHAR)*2) | ||
| 313 | continue; | ||
| 314 | envlist.resize(envlist.size() + tmpSize); | ||
| 305 | static const wchar_t equal = L'='; | ||
| 306 | static const wchar_t nul = L'\0'; | ||
| 315 | 307 | ||
| 316 | tmpSize = it.key().length() * sizeof(TCHAR); | ||
| 317 | memcpy(envlist.data()+pos, it.key().utf16(), tmpSize); | ||
| 318 | pos += tmpSize; | ||
| 308 | for ( ; it != end; ++it) { | ||
| 309 | uint tmpSize = sizeof(wchar_t) * (it.key().length() + it.value().length() + 2); | ||
| 310 | // ignore empty strings | ||
| 311 | if (tmpSize == sizeof(wchar_t) * 2) | ||
| 312 | continue; | ||
| 313 | envlist.resize(envlist.size() + tmpSize); | ||
| 319 | 314 | ||
| 320 | memcpy(envlist.data()+pos, &equal, sizeof(TCHAR)); | ||
| 321 | pos += sizeof(TCHAR); | ||
| 315 | tmpSize = it.key().length() * sizeof(wchar_t); | ||
| 316 | memcpy(envlist.data()+pos, it.key().utf16(), tmpSize); | ||
| 317 | pos += tmpSize; | ||
| 322 | 318 | ||
| 323 | tmpSize = it.value().length() * sizeof(TCHAR); | ||
| 324 | memcpy(envlist.data()+pos, it.value().utf16(), tmpSize); | ||
| 325 | pos += tmpSize; | ||
| 319 | memcpy(envlist.data()+pos, &equal, sizeof(wchar_t)); | ||
| 320 | pos += sizeof(wchar_t); | ||
| 326 | 321 | ||
| 327 | memcpy(envlist.data()+pos, &nul, sizeof(TCHAR)); | ||
| 328 | pos += sizeof(TCHAR); | ||
| 329 | } | ||
| 330 | // add the 2 terminating 0 (actually 4, just to be on the safe side) | ||
| 331 | envlist.resize( envlist.size()+4 ); | ||
| 332 | envlist[pos++] = 0; | ||
| 333 | envlist[pos++] = 0; | ||
| 334 | envlist[pos++] = 0; | ||
| 335 | envlist[pos++] = 0; | ||
| 336 | } else | ||
| 337 | #endif // UNICODE | ||
| 338 | { | ||
| 339 | for ( ; it != end; it++) { | ||
| 340 | QByteArray tmp = it.key().toLocal8Bit(); | ||
| 341 | tmp.append('='); | ||
| 342 | tmp.append(it.value().toLocal8Bit()); | ||
| 322 | tmpSize = it.value().length() * sizeof(wchar_t); | ||
| 323 | memcpy(envlist.data()+pos, it.value().utf16(), tmpSize); | ||
| 324 | pos += tmpSize; | ||
| 343 | 325 | ||
| 344 | uint tmpSize = tmp.length() + 1; | ||
| 345 | envlist.resize(envlist.size() + tmpSize); | ||
| 346 | memcpy(envlist.data()+pos, tmp.data(), tmpSize); | ||
| 347 | pos += tmpSize; | ||
| 348 | } | ||
| 349 | // add the terminating 0 (actually 2, just to be on the safe side) | ||
| 350 | envlist.resize(envlist.size()+2); | ||
| 351 | envlist[pos++] = 0; | ||
| 352 | envlist[pos++] = 0; | ||
| 326 | memcpy(envlist.data()+pos, &nul, sizeof(wchar_t)); | ||
| 327 | pos += sizeof(wchar_t); | ||
| 353 | 328 | } | |
| 329 | // add the 2 terminating 0 (actually 4, just to be on the safe side) | ||
| 330 | envlist.resize( envlist.size()+4 ); | ||
| 331 | envlist[pos++] = 0; | ||
| 332 | envlist[pos++] = 0; | ||
| 333 | envlist[pos++] = 0; | ||
| 334 | envlist[pos++] = 0; | ||
| 354 | 335 | } | |
| 355 | 336 | return envlist; | |
| 356 | 337 | } | |
| … | … | ||
| 372 | 372 | qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes"); | |
| 373 | 373 | #endif | |
| 374 | 374 | ||
| 375 | DWORD dwCreationFlags = 0; | ||
| 376 | if (!(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)) | ||
| 377 | dwCreationFlags |= CREATE_NO_WINDOW; | ||
| 375 | DWORD dwCreationFlags = CREATE_NO_WINDOW; | ||
| 378 | 376 | ||
| 379 | #ifdef UNICODE | ||
| 380 | if (!(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)) { | ||
| 381 | 377 | #if defined(Q_OS_WINCE) | |
| 382 | 378 | QString fullPathProgram = program; | |
| 383 | 379 | if (!QDir::isAbsolutePath(fullPathProgram)) | |
| 384 | 380 | fullPathProgram = QFileInfo(fullPathProgram).absoluteFilePath(); | |
| 385 | 381 | fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\')); | |
| 386 | success = CreateProcessW((WCHAR*)fullPathProgram.utf16(), | ||
| 387 | (WCHAR*)args.utf16(), | ||
| 388 | 0, 0, false, 0, 0, 0, 0, pid); | ||
| 382 | success = CreateProcess((wchar_t*)fullPathProgram.utf16(), | ||
| 383 | (wchar_t*)args.utf16(), | ||
| 384 | 0, 0, false, 0, 0, 0, 0, pid); | ||
| 389 | 385 | #else | |
| 390 | 386 | dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT; | |
| 391 | 387 | STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0, | |
| 392 | 388 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | |
| 393 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | ||
| 394 | 0, 0, 0, | ||
| 395 | STARTF_USESTDHANDLES, | ||
| 396 | 0, 0, 0, | ||
| 397 | stdinChannel.pipe[0], stdoutChannel.pipe[1], stderrChannel.pipe[1] | ||
| 389 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | ||
| 390 | 0, 0, 0, | ||
| 391 | STARTF_USESTDHANDLES, | ||
| 392 | 0, 0, 0, | ||
| 393 | stdinChannel.pipe[0], stdoutChannel.pipe[1], stderrChannel.pipe[1] | ||
| 398 | 394 | }; | |
| 399 | success = CreateProcessW(0, (WCHAR*)args.utf16(), | ||
| 400 | 0, 0, TRUE, dwCreationFlags, | ||
| 401 | environment ? envlist.data() : 0, | ||
| 402 | workingDirectory.isEmpty() ? 0 | ||
| 403 | : (WCHAR*)QDir::toNativeSeparators(workingDirectory).utf16(), | ||
| 404 | &startupInfo, pid); | ||
| 405 | #endif | ||
| 406 | } else | ||
| 407 | #endif // UNICODE | ||
| 408 | { | ||
| 409 | #ifndef Q_OS_WINCE | ||
| 410 | STARTUPINFOA startupInfo = { sizeof( STARTUPINFOA ), 0, 0, 0, | ||
| 411 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | ||
| 412 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | ||
| 413 | 0, 0, 0, | ||
| 414 | STARTF_USESTDHANDLES, | ||
| 415 | 0, 0, 0, | ||
| 416 | stdinChannel.pipe[0], stdoutChannel.pipe[1], stderrChannel.pipe[1] | ||
| 417 | }; | ||
| 395 | success = CreateProcess(0, (wchar_t*)args.utf16(), | ||
| 396 | 0, 0, TRUE, dwCreationFlags, | ||
| 397 | environment ? envlist.data() : 0, | ||
| 398 | workingDirectory.isEmpty() ? 0 | ||
| 399 | : (wchar_t*)QDir::toNativeSeparators(workingDirectory).utf16(), | ||
| 400 | &startupInfo, pid); | ||
| 418 | 401 | ||
| 419 | success = CreateProcessA(0, args.toLocal8Bit().data(), | ||
| 420 | 0, 0, TRUE, dwCreationFlags, environment ? envlist.data() : 0, | ||
| 421 | workingDirectory.isEmpty() ? 0 | ||
| 422 | : QDir::toNativeSeparators(workingDirectory).toLocal8Bit().data(), | ||
| 423 | &startupInfo, pid); | ||
| 424 | #endif // Q_OS_WINCE | ||
| 425 | } | ||
| 426 | #ifndef Q_OS_WINCE | ||
| 427 | 402 | if (stdinChannel.pipe[0] != INVALID_Q_PIPE) { | |
| 428 | 403 | CloseHandle(stdinChannel.pipe[0]); | |
| 429 | 404 | stdinChannel.pipe[0] = INVALID_Q_PIPE; | |
| … | … | ||
| 438 | 438 | } | |
| 439 | 439 | ||
| 440 | 440 | // give the process a chance to start ... | |
| 441 | Sleep(SLEEPMIN*2); | ||
| 441 | Sleep(SLEEPMIN * 2); | ||
| 442 | 442 | _q_startupNotification(); | |
| 443 | 443 | } | |
| 444 | 444 | ||
| … | … | ||
| 812 | 812 | ||
| 813 | 813 | PROCESS_INFORMATION pinfo; | |
| 814 | 814 | ||
| 815 | #ifdef UNICODE | ||
| 816 | if (!(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)) { | ||
| 817 | 815 | #if defined(Q_OS_WINCE) | |
| 818 | 816 | QString fullPathProgram = program; | |
| 819 | 817 | if (!QDir::isAbsolutePath(fullPathProgram)) | |
| 820 | 818 | fullPathProgram.prepend(QDir::currentPath().append(QLatin1Char('/'))); | |
| 821 | 819 | fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\')); | |
| 822 | success = CreateProcessW((WCHAR*)fullPathProgram.utf16(), | ||
| 823 | (WCHAR*)args.utf16(), | ||
| 824 | 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo); | ||
| 820 | success = CreateProcess((wchar_t*)fullPathProgram.utf16(), | ||
| 821 | (wchar_t*)args.utf16(), | ||
| 822 | 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo); | ||
| 825 | 823 | #else | |
| 826 | 824 | STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0, | |
| 827 | 825 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | |
| 828 | 826 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | |
| 829 | 827 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | |
| 830 | 828 | }; | |
| 831 | success = CreateProcessW(0, (WCHAR*)args.utf16(), | ||
| 832 | 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0, | ||
| 833 | workingDir.isEmpty() ? (const WCHAR *)0 : (const WCHAR *)workingDir.utf16(), | ||
| 834 | &startupInfo, &pinfo); | ||
| 835 | #endif | ||
| 836 | } else | ||
| 837 | #endif // UNICODE | ||
| 838 | { | ||
| 839 | #ifndef Q_OS_WINCE | ||
| 840 | STARTUPINFOA startupInfo = { sizeof( STARTUPINFOA ), 0, 0, 0, | ||
| 841 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | ||
| 842 | (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, | ||
| 843 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
| 844 | }; | ||
| 845 | success = CreateProcessA(0, args.toLocal8Bit().data(), | ||
| 846 | 0, 0, FALSE, CREATE_NEW_CONSOLE, 0, | ||
| 847 | workingDir.isEmpty() ? (LPCSTR)0 : workingDir.toLocal8Bit().constData(), | ||
| 829 | success = CreateProcess(0, (wchar_t*)args.utf16(), | ||
| 830 | 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0, | ||
| 831 | workingDir.isEmpty() ? 0 : (wchar_t*)workingDir.utf16(), | ||
| 848 | 832 | &startupInfo, &pinfo); | |
| 849 | 833 | #endif // Q_OS_WINCE | |
| 850 | } | ||
| 851 | 834 | ||
| 852 | 835 | if (success) { | |
| 853 | 836 | CloseHandle(pinfo.hThread); |
src/corelib/io/qsettings.cpp
(6 / 31)
|   | |||
| 1037 | 1037 | // This only happens when bootstrapping qmake. | |
| 1038 | 1038 | #ifndef Q_OS_WINCE | |
| 1039 | 1039 | QLibrary library(QLatin1String("shell32")); | |
| 1040 | QT_WA( { | ||
| 1041 | typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPTSTR, int, BOOL); | ||
| 1042 | GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW"); | ||
| 1043 | if (SHGetSpecialFolderPath) { | ||
| 1044 | TCHAR path[MAX_PATH]; | ||
| 1045 | SHGetSpecialFolderPath(0, path, type, FALSE); | ||
| 1046 | result = QString::fromUtf16((ushort*)path); | ||
| 1047 | } | ||
| 1048 | } , { | ||
| 1049 | typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, char*, int, BOOL); | ||
| 1050 | GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathA"); | ||
| 1051 | if (SHGetSpecialFolderPath) { | ||
| 1052 | char path[MAX_PATH]; | ||
| 1053 | SHGetSpecialFolderPath(0, path, type, FALSE); | ||
| 1054 | result = QString::fromLocal8Bit(path); | ||
| 1055 | } | ||
| 1056 | } ); | ||
| 1057 | 1040 | #else | |
| 1058 | 1041 | QLibrary library(QLatin1String("coredll")); | |
| 1059 | typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPTSTR, int, BOOL); | ||
| 1060 | GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPath"); | ||
| 1042 | #endif // Q_OS_WINCE | ||
| 1043 | typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL); | ||
| 1044 | GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW"); | ||
| 1061 | 1045 | if (SHGetSpecialFolderPath) { | |
| 1062 | 1046 | wchar_t path[MAX_PATH]; | |
| 1063 | 1047 | SHGetSpecialFolderPath(0, path, type, FALSE); | |
| 1064 | result = QString::fromUtf16((ushort*)path); | ||
| 1048 | result = QString::fromWCharArray(path); | ||
| 1065 | 1049 | } | |
| 1066 | #endif // Q_OS_WINCE | ||
| 1067 | 1050 | ||
| 1068 | 1051 | #endif // QT_NO_QOBJECT | |
| 1069 | 1052 | ||
| … | … | ||
| 1442 | 1442 | QString writeSemName = QLatin1String("QSettingsWriteSem "); | |
| 1443 | 1443 | writeSemName.append(file.fileName()); | |
| 1444 | 1444 | ||
| 1445 | QT_WA( { | ||
| 1446 | writeSemaphore = CreateSemaphoreW(0, 1, 1, reinterpret_cast<const wchar_t *>(writeSemName.utf16())); | ||
| 1447 | } , { | ||
| 1448 | writeSemaphore = CreateSemaphoreA(0, 1, 1, writeSemName.toLocal8Bit()); | ||
| 1449 | } ); | ||
| 1445 | writeSemaphore = CreateSemaphore(0, 1, 1, reinterpret_cast<const wchar_t *>(writeSemName.utf16())); | ||
| 1450 | 1446 | ||
| 1451 | 1447 | if (writeSemaphore) { | |
| 1452 | 1448 | WaitForSingleObject(writeSemaphore, INFINITE); | |
| … | … | ||
| 1458 | 1458 | QString readSemName(QLatin1String("QSettingsReadSem ")); | |
| 1459 | 1459 | readSemName.append(file.fileName()); | |
| 1460 | 1460 | ||
| 1461 | QT_WA( { | ||
| 1462 | readSemaphore = CreateSemaphoreW(0, FileLockSemMax, FileLockSemMax, reinterpret_cast<const wchar_t *>(readSemName.utf16())); | ||
| 1463 | } , { | ||
| 1464 | readSemaphore = CreateSemaphoreA(0, FileLockSemMax, FileLockSemMax, readSemName.toLocal8Bit()); | ||
| 1465 | } ); | ||
| 1461 | readSemaphore = CreateSemaphore(0, FileLockSemMax, FileLockSemMax, reinterpret_cast<const wchar_t *>(readSemName.utf16())); | ||
| 1466 | 1462 | ||
| 1467 | 1463 | if (readSemaphore) { | |
| 1468 | 1464 | for (int i = 0; i < numReadLocks; ++i) |
src/corelib/io/qsettings_win.cpp
(38 / 171)
|   | |||
| 130 | 130 | ||
| 131 | 131 | static QString errorCodeToString(DWORD errorCode) | |
| 132 | 132 | { | |
| 133 | QString result; | ||
| 134 | QT_WA({ | ||
| 135 | wchar_t *data = 0; | ||
| 136 | FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, | ||
| 137 | 0, errorCode, 0, | ||
| 138 | data, 0, 0); | ||
| 139 | result = QString::fromUtf16(reinterpret_cast<const ushort *> (data)); | ||
| 140 | if (data != 0) | ||
| 141 | LocalFree(data); | ||
| 142 | }, { | ||
| 143 | char *data = 0; | ||
| 144 | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, | ||
| 145 | 0, errorCode, 0, | ||
| 146 | (char *)&data, 0, 0); | ||
| 147 | result = QString::fromLocal8Bit(data); | ||
| 148 | if (data != 0) | ||
| 149 | LocalFree(data); | ||
| 150 | }) | ||
| 133 | wchar_t *data = 0; | ||
| 134 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, 0, 0); | ||
| 135 | QString result = QString::fromWCharArray(data); | ||
| 136 | |||
| 137 | if (data != 0) | ||
| 138 | LocalFree(data); | ||
| 139 | |||
| 151 | 140 | if (result.endsWith(QLatin1Char('\n'))) | |
| 152 | 141 | result.truncate(result.length() - 1); | |
| 153 | 142 | ||
| … | … | ||
| 147 | 147 | static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey) | |
| 148 | 148 | { | |
| 149 | 149 | HKEY resultHandle = 0; | |
| 150 | |||
| 151 | LONG res; | ||
| 152 | QT_WA( { | ||
| 153 | res = RegOpenKeyExW(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), | ||
| 150 | LONG res = RegOpenKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), | ||
| 154 | 151 | 0, perms, &resultHandle); | |
| 155 | } , { | ||
| 156 | res = RegOpenKeyExA(parentHandle, rSubKey.toLocal8Bit(), | ||
| 157 | 0, perms, &resultHandle); | ||
| 158 | } ); | ||
| 159 | 152 | ||
| 160 | 153 | if (res == ERROR_SUCCESS) | |
| 161 | 154 | return resultHandle; | |
| … | … | ||
| 165 | 165 | return resultHandle; | |
| 166 | 166 | ||
| 167 | 167 | // try to create it | |
| 168 | LONG res; | ||
| 169 | QT_WA( { | ||
| 170 | res = RegCreateKeyExW(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), 0, 0, | ||
| 168 | LONG res = RegCreateKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), 0, 0, | ||
| 171 | 169 | REG_OPTION_NON_VOLATILE, perms, 0, &resultHandle, 0); | |
| 172 | } , { | ||
| 173 | res = RegCreateKeyExA(parentHandle, rSubKey.toLocal8Bit(), 0, 0, | ||
| 174 | REG_OPTION_NON_VOLATILE, perms, 0, &resultHandle, 0); | ||
| 175 | } ); | ||
| 176 | 170 | ||
| 177 | 171 | if (res == ERROR_SUCCESS) | |
| 178 | 172 | return resultHandle; | |
| … | … | ||
| 201 | 201 | static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildSpec spec) | |
| 202 | 202 | { | |
| 203 | 203 | QStringList result; | |
| 204 | LONG res; | ||
| 205 | 204 | DWORD numKeys; | |
| 206 | 205 | DWORD maxKeySize; | |
| 207 | 206 | DWORD numSubgroups; | |
| 208 | 207 | DWORD maxSubgroupSize; | |
| 209 | 208 | ||
| 210 | 209 | // Find the number of keys and subgroups, as well as the max of their lengths. | |
| 211 | QT_WA( { | ||
| 212 | res = RegQueryInfoKeyW(parentHandle, 0, 0, 0, &numSubgroups, &maxSubgroupSize, 0, | ||
| 210 | LONG res = RegQueryInfoKey(parentHandle, 0, 0, 0, &numSubgroups, &maxSubgroupSize, 0, | ||
| 213 | 211 | &numKeys, &maxKeySize, 0, 0, 0); | |
| 214 | }, { | ||
| 215 | res = RegQueryInfoKeyA(parentHandle, 0, 0, 0, &numSubgroups, &maxSubgroupSize, 0, | ||
| 216 | &numKeys, &maxKeySize, 0, 0, 0); | ||
| 217 | } ); | ||
| 218 | 212 | ||
| 219 | 213 | if (res != ERROR_SUCCESS) { | |
| 220 | 214 | qWarning("QSettings: RegQueryInfoKey() failed: %s", errorCodeToString(res).toLatin1().data()); | |
| … | … | ||
| 228 | 228 | m = maxSubgroupSize; | |
| 229 | 229 | } | |
| 230 | 230 | ||
| 231 | /* Windows NT/2000/XP: The size does not include the terminating null character. | ||
| 232 | Windows Me/98/95: The size includes the terminating null character. */ | ||
| 231 | /* The size does not include the terminating null character. */ | ||
| 233 | 232 | ++m; | |
| 234 | 233 | ||
| 235 | 234 | // Get the list | |
| 236 | QByteArray buff(m*sizeof(ushort), 0); | ||
| 235 | QByteArray buff(m * sizeof(wchar_t), 0); | ||
| 237 | 236 | for (int i = 0; i < n; ++i) { | |
| 238 | 237 | QString item; | |
| 239 | QT_WA( { | ||
| 240 | DWORD l = buff.size() / sizeof(ushort); | ||
| 241 | if (spec == QSettingsPrivate::ChildKeys) { | ||
| 242 | res = RegEnumValueW(parentHandle, i, | ||
| 243 | reinterpret_cast<wchar_t *>(buff.data()), | ||
| 244 | &l, 0, 0, 0, 0); | ||
| 245 | } else { | ||
| 246 | res = RegEnumKeyExW(parentHandle, i, | ||
| 247 | reinterpret_cast<wchar_t *>(buff.data()), | ||
| 248 | &l, 0, 0, 0, 0); | ||
| 249 | } | ||
| 250 | if (res == ERROR_SUCCESS) | ||
| 251 | item = QString::fromUtf16(reinterpret_cast<ushort*>(buff.data()), l); | ||
| 252 | }, { | ||
| 253 | DWORD l = buff.size(); | ||
| 254 | if (spec == QSettingsPrivate::ChildKeys) | ||
| 255 | res = RegEnumValueA(parentHandle, i, buff.data(), &l, 0, 0, 0, 0); | ||
| 256 | else | ||
| 257 | res = RegEnumKeyExA(parentHandle, i, buff.data(), &l, 0, 0, 0, 0); | ||
| 258 | if (res == ERROR_SUCCESS) | ||
| 259 | item = QString::fromLocal8Bit(buff.data(), l); | ||
| 260 | } ); | ||
| 238 | DWORD l = buff.size() / sizeof(wchar_t); | ||
| 239 | if (spec == QSettingsPrivate::ChildKeys) { | ||
| 240 | res = RegEnumValue(parentHandle, i, reinterpret_cast<wchar_t *>(buff.data()), &l, 0, 0, 0, 0); | ||
| 241 | } else { | ||
| 242 | res = RegEnumKeyEx(parentHandle, i, reinterpret_cast<wchar_t *>(buff.data()), &l, 0, 0, 0, 0); | ||
| 243 | } | ||
| 244 | if (res == ERROR_SUCCESS) | ||
| 245 | item = QString::fromWCharArray((const wchar_t *)buff.constData(), l); | ||
| 261 | 246 | ||
| 262 | 247 | if (res != ERROR_SUCCESS) { | |
| 263 | 248 | qWarning("QSettings: RegEnumValue failed: %s", errorCodeToString(res).toLatin1().data()); | |
| … | … | ||
| 297 | 297 | RegCloseKey(childGroupHandle); | |
| 298 | 298 | ||
| 299 | 299 | // delete group itself | |
| 300 | LONG res; | ||
| 301 | QT_WA( { | ||
| 302 | res = RegDeleteKeyW(parentHandle, reinterpret_cast<const wchar_t *>(group.utf16())); | ||
| 303 | }, { | ||
| 304 | res = RegDeleteKeyA(parentHandle, group.toLocal8Bit()); | ||
| 305 | } ); | ||
| 300 | LONG res = RegDeleteKey(parentHandle, reinterpret_cast<const wchar_t *>(group.utf16())); | ||
| 306 | 301 | if (res != ERROR_SUCCESS) { | |
| 307 | 302 | qWarning("QSettings: RegDeleteKey failed on subkey \"%s\": %s", | |
| 308 | 303 | group.toLatin1().data(), errorCodeToString(res).toLatin1().data()); | |
| … | … | ||
| 469 | 469 | // get the size and type of the value | |
| 470 | 470 | DWORD dataType; | |
| 471 | 471 | DWORD dataSize; | |
| 472 | LONG res; | ||
| 473 | QT_WA( { | ||
| 474 | res = RegQueryValueExW(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.utf16()), 0, &dataType, 0, &dataSize); | ||
| 475 | }, { | ||
| 476 | res = RegQueryValueExA(handle, rSubkeyName.toLocal8Bit(), 0, &dataType, 0, &dataSize); | ||
| 477 | } ); | ||
| 472 | LONG res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.utf16()), 0, &dataType, 0, &dataSize); | ||
| 478 | 473 | if (res != ERROR_SUCCESS) { | |
| 479 | 474 | RegCloseKey(handle); | |
| 480 | 475 | return false; | |
| … | … | ||
| 477 | 477 | ||
| 478 | 478 | // get the value | |
| 479 | 479 | QByteArray data(dataSize, 0); | |
| 480 | QT_WA( { | ||
| 481 | res = RegQueryValueExW(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.utf16()), 0, 0, | ||
| 482 | reinterpret_cast<unsigned char*>(data.data()), &dataSize); | ||
| 483 | }, { | ||
| 484 | res = RegQueryValueExA(handle, rSubkeyName.toLocal8Bit(), 0, 0, | ||
| 485 | reinterpret_cast<unsigned char*>(data.data()), &dataSize); | ||
| 486 | } ); | ||
| 480 | res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.utf16()), 0, 0, | ||
| 481 | reinterpret_cast<unsigned char*>(data.data()), &dataSize); | ||
| 487 | 482 | if (res != ERROR_SUCCESS) { | |
| 488 | 483 | RegCloseKey(handle); | |
| 489 | 484 | return false; | |
| … | … | ||
| 489 | 489 | case REG_SZ: { | |
| 490 | 490 | QString s; | |
| 491 | 491 | if (dataSize) { | |
| 492 | QT_WA( { | ||
| 493 | s = QString::fromUtf16(((const ushort*)data.constData())); | ||
| 494 | }, { | ||
| 495 | s = QString::fromLocal8Bit(data.constData()); | ||
| 496 | } ); | ||
| 492 | s = QString::fromWCharArray(((const wchar_t *)data.constData())); | ||
| 497 | 493 | } | |
| 498 | 494 | if (value != 0) | |
| 499 | 495 | *value = stringToVariant(s); | |
| … | … | ||
| 501 | 501 | if (dataSize) { | |
| 502 | 502 | int i = 0; | |
| 503 | 503 | for (;;) { | |
| 504 | QString s; | ||
| 505 | QT_WA( { | ||
| 506 | s = QString::fromUtf16((const ushort*)data.constData() + i); | ||
| 507 | }, { | ||
| 508 | s = QString::fromLocal8Bit(data.constData() + i); | ||
| 509 | } ); | ||
| 504 | QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i); | ||
| 510 | 505 | i += s.length() + 1; | |
| 511 | 506 | ||
| 512 | 507 | if (s.isEmpty()) | |
| … | … | ||
| 518 | 518 | case REG_BINARY: { | |
| 519 | 519 | QString s; | |
| 520 | 520 | if (dataSize) { | |
| 521 | QT_WA( { | ||
| 522 | s = QString::fromUtf16((const ushort*)data.constData(), data.size()/2); | ||
| 523 | }, { | ||
| 524 | s = QString::fromLocal8Bit(data.constData(), data.size()); | ||
| 525 | } ); | ||
| 521 | s = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); | ||
| 526 | 522 | } | |
| 527 | 523 | if (value != 0) | |
| 528 | 524 | *value = stringToVariant(s); | |
| … | … | ||
| 562 | 562 | #if defined(Q_OS_WINCE) | |
| 563 | 563 | remove(regList.at(0).key()); | |
| 564 | 564 | #else | |
| 565 | DWORD res; | ||
| 566 | 565 | QString emptyKey; | |
| 567 | QT_WA( { | ||
| 568 | res = RegDeleteKeyW(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16())); | ||
| 569 | }, { | ||
| 570 | res = RegDeleteKeyA(writeHandle(), emptyKey.toLocal8Bit()); | ||
| 571 | } ); | ||
| 566 | DWORD res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16())); | ||
| 572 | 567 | if (res != ERROR_SUCCESS) { | |
| 573 | 568 | qWarning("QSettings: Failed to delete key \"%s\": %s", | |
| 574 | 569 | regList.at(0).key().toLatin1().data(), errorCodeToString(res).toLatin1().data()); | |
| … | … | ||
| 588 | 588 | LONG res; | |
| 589 | 589 | HKEY handle = openKey(writeHandle(), registryPermissions, keyPath(rKey)); | |
| 590 | 590 | if (handle != 0) { | |
| 591 | QT_WA( { | ||
| 592 | res = RegDeleteValueW(handle, reinterpret_cast<const wchar_t *>(keyName(rKey).utf16())); | ||
| 593 | }, { | ||
| 594 | res = RegDeleteValueA(handle, keyName(rKey).toLocal8Bit()); | ||
| 595 | } ); | ||
| 591 | res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(keyName(rKey).utf16())); | ||
| 596 | 592 | RegCloseKey(handle); | |
| 597 | 593 | } | |
| 598 | 594 | ||
| … | … | ||
| 603 | 603 | for (int i = 0; i < childKeys.size(); ++i) { | |
| 604 | 604 | QString group = childKeys.at(i); | |
| 605 | 605 | ||
| 606 | LONG res; | ||
| 607 | QT_WA( { | ||
| 608 | res = RegDeleteValueW(handle, reinterpret_cast<const wchar_t *>(group.utf16())); | ||
| 609 | }, { | ||
| 610 | res = RegDeleteValueA(handle, group.toLocal8Bit()); | ||
| 611 | } ); | ||
| 606 | LONG res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(group.utf16())); | ||
| 612 | 607 | if (res != ERROR_SUCCESS) { | |
| 613 | 608 | qWarning("QSettings: RegDeleteValue failed on subkey \"%s\": %s", | |
| 614 | 609 | group.toLatin1().data(), errorCodeToString(res).toLatin1().data()); | |
| … | … | ||
| 614 | 614 | // For WinCE always Close the handle first. | |
| 615 | 615 | RegCloseKey(handle); | |
| 616 | 616 | #endif | |
| 617 | QT_WA( { | ||
| 618 | res = RegDeleteKeyW(writeHandle(), reinterpret_cast<const wchar_t *>(rKey.utf16())); | ||
| 619 | }, { | ||
| 620 | res = RegDeleteKeyA(writeHandle(), rKey.toLocal8Bit()); | ||
| 621 | } ); | ||
| 617 | res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(rKey.utf16())); | ||
| 622 | 618 | ||
| 623 | 619 | if (res != ERROR_SUCCESS) { | |
| 624 | 620 | qWarning("QSettings: RegDeleteKey failed on key \"%s\": %s", | |
| … | … | ||
| 670 | 670 | ||
| 671 | 671 | if (type == REG_BINARY) { | |
| 672 | 672 | QString s = variantToString(value); | |
| 673 | QT_WA( { | ||
| 674 | regValueBuff = QByteArray((const char*)s.utf16(), s.length()*2); | ||
| 675 | }, { | ||
| 676 | regValueBuff = QByteArray((const char*)s.toLocal8Bit(), s.length()); | ||
| 677 | } ); | ||
| 673 | regValueBuff = QByteArray((const char*)s.utf16(), s.length() * 2); | ||
| 678 | 674 | } else { | |
| 679 | 675 | QStringList::const_iterator it = l.constBegin(); | |
| 680 | 676 | for (; it != l.constEnd(); ++it) { | |
| 681 | 677 | const QString &s = *it; | |
| 682 | QT_WA( { | ||
| 683 | regValueBuff += QByteArray((const char*)s.utf16(), (s.length() + 1)*2); | ||
| 684 | }, { | ||
| 685 | regValueBuff += QByteArray((const char*)s.toLocal8Bit(), s.length() + 1); | ||
| 686 | } ); | ||
| 678 | regValueBuff += QByteArray((const char*)s.utf16(), (s.length() + 1) * 2); | ||
| 687 | 679 | } | |
| 688 | QT_WA( { | ||
| 689 | regValueBuff.append((char)0); | ||
| 690 | regValueBuff.append((char)0); | ||
| 691 | }, { | ||
| 692 | regValueBuff.append((char)0); | ||
| 693 | } ); | ||
| 680 | regValueBuff.append((char)0); | ||
| 681 | regValueBuff.append((char)0); | ||
| 694 | 682 | } | |
| 695 | 683 | break; | |
| 696 | 684 | } | |
| … | … | ||
| 691 | 691 | } | |
| 692 | 692 | ||
| 693 | 693 | case QVariant::ByteArray: | |
| 694 | // On Win95/98/Me QString::toLocal8Bit() fails to handle chars > 0x7F. So we don't go through variantToString() at all. | ||
| 695 | if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { | ||
| 696 | QByteArray ba = value.toByteArray(); | ||
| 697 | regValueBuff = "@ByteArray("; | ||
| 698 | regValueBuff += ba; | ||
| 699 | regValueBuff += ')'; | ||
| 700 | if (ba.contains('\0')) { | ||
| 701 | type = REG_BINARY; | ||
| 702 | } else { | ||
| 703 | type = REG_SZ; | ||
| 704 | regValueBuff += '\0'; | ||
| 705 | } | ||
| 706 | |||
| 707 | break; | ||
| 708 | } | ||
| 709 | 694 | // fallthrough intended | |
| 710 | 695 | ||
| 711 | 696 | default: { | |
| … | … | ||
| 699 | 699 | QString s = variantToString(value); | |
| 700 | 700 | type = stringContainsNullChar(s) ? REG_BINARY : REG_SZ; | |
| 701 | 701 | if (type == REG_BINARY) { | |
| 702 | QT_WA( { | ||
| 703 | regValueBuff = QByteArray((const char*)s.utf16(), s.length()*2); | ||
| 704 | }, { | ||
| 705 | regValueBuff = QByteArray((const char*)s.toLocal8Bit(), s.length()); | ||
| 706 | } ); | ||
| 702 | regValueBuff = QByteArray((const char*)s.utf16(), s.length() * 2); | ||
| 707 | 703 | } else { | |
| 708 | QT_WA( { | ||
| 709 | regValueBuff = QByteArray((const char*)s.utf16(), (s.length() + 1)*2); | ||
| 710 | }, { | ||
| 711 | regValueBuff = QByteArray((const char*)s.toLocal8Bit(), s.length() + 1); | ||
| 712 | } ); | ||
| 704 | regValueBuff = QByteArray((const char*)s.utf16(), (s.length() + 1) * 2); | ||
| 713 | 705 | } | |
| 714 | 706 | break; | |
| 715 | 707 | } | |
| 716 | 708 | } | |
| 717 | 709 | ||
| 718 | 710 | // set the value | |
| 719 | LONG res; | ||
| 720 | QT_WA( { | ||
| 721 | res = RegSetValueExW(handle, reinterpret_cast<const wchar_t *>(keyName(rKey).utf16()), 0, type, | ||
| 711 | LONG res = RegSetValueEx(handle, reinterpret_cast<const wchar_t *>(keyName(rKey).utf16()), 0, type, | ||
| 722 | 712 | reinterpret_cast<const unsigned char*>(regValueBuff.constData()), | |
| 723 | 713 | regValueBuff.size()); | |
| 724 | }, { | ||
| 725 | res = RegSetValueExA(handle, keyName(rKey).toLocal8Bit(), 0, type, | ||
| 726 | reinterpret_cast<const unsigned char*>(regValueBuff.constData()), | ||
| 727 | regValueBuff.size()); | ||
| 728 | } ); | ||
| 729 | 714 | ||
| 730 | 715 | if (res == ERROR_SUCCESS) { | |
| 731 | 716 | deleteWriteHandleOnExit = false; |
|   | |||
| 1742 | 1742 | return d->cachedApplicationFilePath; | |
| 1743 | 1743 | ||
| 1744 | 1744 | #if defined( Q_WS_WIN ) | |
| 1745 | QFileInfo filePath; | ||
| 1746 | QT_WA({ | ||
| 1747 | wchar_t module_name[MAX_PATH+1]; | ||
| 1748 | GetModuleFileNameW(0, module_name, MAX_PATH); | ||
| 1749 | module_name[MAX_PATH] = 0; | ||
| 1750 | filePath = QString::fromUtf16((ushort *)module_name); | ||
| 1751 | }, { | ||
| 1752 | char module_name[MAX_PATH+1]; | ||
| 1753 | GetModuleFileNameA(0, module_name, MAX_PATH); | ||
| 1754 | module_name[MAX_PATH] = 0; | ||
| 1755 | filePath = QString::fromLocal8Bit(module_name); | ||
| 1756 | }); | ||
| 1745 | wchar_t module_name[MAX_PATH]; | ||
| 1746 | GetModuleFileName(0, module_name, MAX_PATH); | ||
| 1747 | module_name[MAX_PATH] = 0; | ||
| 1748 | QFileInfo filePath = QString::fromWCharArray(module_name); | ||
| 1757 | 1749 | ||
| 1758 | 1750 | d->cachedApplicationFilePath = filePath.filePath(); | |
| 1759 | 1751 | return d->cachedApplicationFilePath; | |
| … | … | ||
| 1894 | 1894 | return list; | |
| 1895 | 1895 | } | |
| 1896 | 1896 | #ifdef Q_OS_WIN | |
| 1897 | QString cmdline = QT_WA_INLINE(QString::fromUtf16((unsigned short *)GetCommandLineW()), QString::fromLocal8Bit(GetCommandLineA())); | ||
| 1897 | QString cmdline = QString::fromWCharArray(GetCommandLine()); | ||
| 1898 | 1898 | ||
| 1899 | 1899 | #if defined(Q_OS_WINCE) | |
| 1900 | 1900 | wchar_t tempFilename[MAX_PATH+1]; | |
| 1901 | if (GetModuleFileNameW(0, tempFilename, MAX_PATH)) { | ||
| 1901 | if (GetModuleFileName(0, tempFilename, MAX_PATH)) { | ||
| 1902 | 1902 | tempFilename[MAX_PATH] = 0; | |
| 1903 | cmdline.prepend(QLatin1Char('\"') + QString::fromUtf16((unsigned short *)tempFilename) + QLatin1String("\" ")); | ||
| 1903 | cmdline.prepend(QLatin1Char('\"') + QString::fromWCharArray(tempFilename) + QLatin1String("\" ")); | ||
| 1904 | 1904 | } | |
| 1905 | 1905 | #endif // Q_OS_WINCE | |
| 1906 | 1906 |
|   | |||
| 45 | 45 | #include "qt_windows.h" | |
| 46 | 46 | #include "qvector.h" | |
| 47 | 47 | #include "qmutex.h" | |
| 48 | #include "qfileinfo.h" | ||
| 48 | 49 | #include "qcorecmdlineargs_p.h" | |
| 49 | 50 | #include <private/qthread_p.h> | |
| 50 | 51 | #include <ctype.h> | |
| 51 | 52 | ||
| 52 | 53 | QT_BEGIN_NAMESPACE | |
| 53 | 54 | ||
| 54 | char appFileName[MAX_PATH+1]; // application file name | ||
| 55 | char theAppName[MAX_PATH+1]; // application name | ||
| 55 | char appFileName[MAX_PATH]; // application file name | ||
| 56 | char theAppName[MAX_PATH]; // application name | ||
| 56 | 57 | HINSTANCE appInst = 0; // handle to app instance | |
| 57 | 58 | HINSTANCE appPrevInst = 0; // handle to prev app instance | |
| 58 | 59 | int appCmdShow = 0; | |
| … | … | ||
| 74 | 74 | return appCmdShow; | |
| 75 | 75 | } | |
| 76 | 76 | ||
| 77 | Q_CORE_EXPORT QString qAppFileName() // get application file name | ||
| 78 | { | ||
| 79 | wchar_t buffer[MAX_PATH]; | ||
| 80 | GetModuleFileName(0, buffer, MAX_PATH); | ||
| 81 | return QString::fromWCharArray(buffer); | ||
| 82 | } | ||
| 77 | 83 | ||
| 78 | 84 | void set_winapp_name() | |
| 79 | 85 | { | |
| 80 | 86 | static bool already_set = false; | |
| 81 | 87 | if (!already_set) { | |
| 82 | 88 | already_set = true; | |
| 83 | #ifndef Q_OS_WINCE | ||
| 84 | GetModuleFileNameA(0, appFileName, sizeof(appFileName)); | ||
| 85 | appFileName[sizeof(appFileName)-1] = 0; | ||
| 86 | #else | ||
| 87 | QString afm; | ||
| 88 | afm.resize(sizeof(appFileName)); | ||
| 89 | afm.resize(GetModuleFileName(0, (wchar_t *) (afm.unicode()), sizeof(appFileName))); | ||
| 90 | memcpy(appFileName, afm.toLatin1(), sizeof(appFileName)); | ||
| 91 | #endif | ||
| 92 | const char *p = strrchr(appFileName, '\\'); // skip path | ||
| 93 | if (p) | ||
| 94 | memcpy(theAppName, p+1, qstrlen(p)); | ||
| 95 | int l = qstrlen(theAppName); | ||
| 96 | if ((l > 4) && !qstricmp(theAppName + l - 4, ".exe")) | ||
| 97 | theAppName[l-4] = '\0'; // drop .exe extension | ||
| 98 | 89 | ||
| 99 | if (appInst == 0) { | ||
| 100 | QT_WA({ | ||
| 101 | appInst = GetModuleHandle(0); | ||
| 102 | }, { | ||
| 103 | appInst = GetModuleHandleA(0); | ||
| 104 | }); | ||
| 105 | } | ||
| 90 | QString moduleName = qAppFileName(); | ||
| 91 | |||
| 92 | QByteArray filePath = moduleName.toLocal8Bit(); | ||
| 93 | QByteArray fileName = QFileInfo(moduleName).baseName().toLocal8Bit(); | ||
| 94 | |||
| 95 | memcpy(appFileName, filePath.constData(), filePath.length()); | ||
| 96 | memcpy(theAppName, fileName.constData(), fileName.length()); | ||
| 97 | |||
| 98 | if (appInst == 0) | ||
| 99 | appInst = GetModuleHandle(0); | ||
| 106 | 100 | } | |
| 107 | 101 | } | |
| 108 | 102 | ||
| 109 | Q_CORE_EXPORT QString qAppFileName() // get application file name | ||
| 110 | { | ||
| 111 | return QString::fromLatin1(appFileName); | ||
| 112 | } | ||
| 113 | |||
| 114 | 103 | QString QCoreApplicationPrivate::appName() const | |
| 115 | 104 | { | |
| 116 | if (!theAppName[0]) | ||
| 117 | set_winapp_name(); | ||
| 118 | return QString::fromLatin1(theAppName); | ||
| 105 | return QFileInfo(qAppFileName()).baseName(); | ||
| 119 | 106 | } | |
| 120 | 107 | ||
| 121 | 108 | class QWinMsgHandlerCriticalSection | |
| … | … | ||
| 133 | 133 | str = "(null)"; | |
| 134 | 134 | ||
| 135 | 135 | staticCriticalSection.lock(); | |
| 136 | QT_WA({ | ||
| 137 | QString s(QString::fromLocal8Bit(str)); | ||
| 138 | s += QLatin1Char('\n'); | ||
| 139 | OutputDebugStringW((TCHAR*)s.utf16()); | ||
| 140 | }, { | ||
| 141 | QByteArray s(str); | ||
| 142 | s += '\n'; | ||
| 143 | OutputDebugStringA(s.data()); | ||
| 144 | }) | ||
| 136 | |||
| 137 | QString s(QString::fromLocal8Bit(str)); | ||
| 138 | s += QLatin1Char('\n'); | ||
| 139 | OutputDebugString((wchar_t*)s.utf16()); | ||
| 140 | |||
| 145 | 141 | staticCriticalSection.unlock(); | |
| 146 | 142 | } | |
| 147 | 143 |
|   | |||
| 135 | 135 | QStringList args; | |
| 136 | 136 | ||
| 137 | 137 | int argc = 0; | |
| 138 | QVector<ushort*> argv = qWinCmdLine<ushort>((ushort*)cmdLine.utf16(), cmdLine.length(), argc); | ||
| 138 | QVector<wchar_t*> argv = qWinCmdLine<wchar_t>((wchar_t *)cmdLine.utf16(), cmdLine.length(), argc); | ||
| 139 | 139 | for (int a = 0; a < argc; ++a) { | |
| 140 | args << QString::fromUtf16(argv[a]); | ||
| 140 | args << QString::fromWCharArray(argv[a]); | ||
| 141 | 141 | } | |
| 142 | 142 | ||
| 143 | 143 | return args; | |
| … | … | ||
| 147 | 147 | { | |
| 148 | 148 | Q_UNUSED(argc) | |
| 149 | 149 | Q_UNUSED(argv) | |
| 150 | QString cmdLine = QT_WA_INLINE( | ||
| 151 | QString::fromUtf16((unsigned short*)GetCommandLineW()), | ||
| 152 | QString::fromLocal8Bit(GetCommandLineA()) | ||
| 153 | ); | ||
| 150 | QString cmdLine = QString::fromWCharArray(GetCommandLine()); | ||
| 154 | 151 | return qWinCmdArgs(cmdLine); | |
| 155 | 152 | } | |
| 156 | 153 |
|   | |||
| 355 | 355 | { | |
| 356 | 356 | resolveTimerAPI(); | |
| 357 | 357 | ||
| 358 | wakeUpNotifier.setHandle(QT_WA_INLINE(CreateEventW(0, FALSE, FALSE, 0), | ||
| 359 | CreateEventA(0, FALSE, FALSE, 0))); | ||
| 358 | wakeUpNotifier.setHandle(CreateEvent(0, FALSE, FALSE, 0)); | ||
| 360 | 359 | if (!wakeUpNotifier.handle()) | |
| 361 | 360 | qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed"); | |
| 362 | 361 | } | |
| … | … | ||
| 366 | 366 | CloseHandle(wakeUpNotifier.handle()); | |
| 367 | 367 | if (internalHwnd) | |
| 368 | 368 | DestroyWindow(internalHwnd); | |
| 369 | QByteArray className = "QEventDispatcherWin32_Internal_Widget" + QByteArray::number(quintptr(qt_internal_proc)); | ||
| 370 | #if !defined(Q_OS_WINCE) | ||
| 371 | UnregisterClassA(className.constData(), qWinAppInst()); | ||
| 372 | #else | ||
| 373 | UnregisterClassW(reinterpret_cast<const wchar_t *> (QString::fromLatin1(className.constData()).utf16()) | ||
| 374 | , qWinAppInst()); | ||
| 375 | #endif | ||
| 369 | QString className = QLatin1String("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc)); | ||
| 370 | UnregisterClass((wchar_t*)className.utf16(), qWinAppInst()); | ||
| 376 | 371 | } | |
| 377 | 372 | ||
| 378 | 373 | void QEventDispatcherWin32Private::activateEventNotifier(QWinEventNotifier * wen) | |
| … | … | ||
| 376 | 376 | QCoreApplication::sendEvent(wen, &event); | |
| 377 | 377 | } | |
| 378 | 378 | ||
| 379 | |||
| 379 | // ### Qt 5: remove | ||
| 380 | 380 | Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin, | |
| 381 | 381 | UINT wMsgFilterMax, UINT wRemoveMsg) | |
| 382 | 382 | { | |
| 383 | QT_WA({ return PeekMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); } , | ||
| 384 | { return PeekMessageA(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); }); | ||
| 383 | return PeekMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); | ||
| 385 | 384 | } | |
| 386 | 385 | ||
| 386 | // ### Qt 5: remove | ||
| 387 | 387 | Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
| 388 | 388 | { | |
| 389 | QT_WA({ return PostMessage(hWnd, msg, wParam, lParam); } , | ||
| 390 | { return PostMessageA(hWnd, msg, wParam, lParam); }); | ||
| 389 | return PostMessage(hWnd, msg, wParam, lParam); | ||
| 391 | 390 | } | |
| 392 | 391 | ||
| 392 | // ### Qt 5: remove | ||
| 393 | Q_CORE_EXPORT bool winGetMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin, | ||
| 394 | UINT wMsgFilterMax) | ||
| 395 | { | ||
| 396 | return GetMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax); | ||
| 397 | } | ||
| 398 | |||
| 393 | 399 | // This function is called by a workerthread | |
| 394 | 400 | void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_PTR user, DWORD_PTR /*reserved*/, DWORD_PTR /*reserved*/) | |
| 395 | 401 | { | |
| … | … | ||
| 443 | 443 | ||
| 444 | 444 | #ifdef GWLP_USERDATA | |
| 445 | 445 | QEventDispatcherWin32 *eventDispatcher = | |
| 446 | (QEventDispatcherWin32 *) GetWindowLongPtrA(hwnd, GWLP_USERDATA); | ||
| 446 | (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | ||
| 447 | 447 | #else | |
| 448 | 448 | QEventDispatcherWin32 *eventDispatcher = | |
| 449 | (QEventDispatcherWin32 *) GetWindowLongA(hwnd, GWL_USERDATA); | ||
| 449 | (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA); | ||
| 450 | 450 | #endif | |
| 451 | 451 | if (eventDispatcher) { | |
| 452 | 452 | QEventDispatcherWin32Private *d = eventDispatcher->d_func(); | |
| … | … | ||
| 494 | 494 | ||
| 495 | 495 | static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher) | |
| 496 | 496 | { | |
| 497 | HINSTANCE hi = qWinAppInst(); | ||
| 498 | #if defined(Q_OS_WINCE) | ||
| 497 | // make sure that multiple Qt's can coexist in the same process | ||
| 498 | QString className = QLatin1Strign("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc)); | ||
| 499 | |||
| 499 | 500 | WNDCLASS wc; | |
| 500 | #else | ||
| 501 | WNDCLASSA wc; | ||
| 502 | #endif | ||
| 503 | 501 | wc.style = 0; | |
| 504 | 502 | wc.lpfnWndProc = qt_internal_proc; | |
| 505 | 503 | wc.cbClsExtra = 0; | |
| 506 | 504 | wc.cbWndExtra = 0; | |
| 507 | wc.hInstance = hi; | ||
| 505 | wc.hInstance = qWinAppInst(); | ||
| 508 | 506 | wc.hIcon = 0; | |
| 509 | 507 | wc.hCursor = 0; | |
| 510 | 508 | wc.hbrBackground = 0; | |
| 511 | 509 | wc.lpszMenuName = NULL; | |
| 510 | wc.lpszClassName = reinterpret_cast<const wchar_t *> (className.utf16()); | ||
| 512 | 511 | ||
| 513 | // make sure that multiple Qt's can coexist in the same process | ||
| 514 | QByteArray className = "QEventDispatcherWin32_Internal_Widget" + QByteArray::number(quintptr(qt_internal_proc)); | ||
| 515 | #if defined(Q_OS_WINCE) | ||
| 516 | QString tmp = QString::fromLatin1(className.data()); | ||
| 517 | wc.lpszClassName = reinterpret_cast<const wchar_t *> (tmp.utf16()); | ||
| 518 | 512 | RegisterClass(&wc); | |
| 519 | 513 | HWND wnd = CreateWindow(wc.lpszClassName, // classname | |
| 520 | wc.lpszClassName, // window name | ||
| 521 | 0, // style | ||
| 522 | 0, 0, 0, 0, // geometry | ||
| 523 | 0, // parent | ||
| 524 | 0, // menu handle | ||
| 525 | hi, // application | ||
| 526 | 0); // windows creation data. | ||
| 527 | #else | ||
| 528 | wc.lpszClassName = className.constData(); | ||
| 529 | RegisterClassA(&wc); | ||
| 530 | HWND wnd = CreateWindowA(wc.lpszClassName, // classname | ||
| 531 | wc.lpszClassName, // window name | ||
| 532 | 0, // style | ||
| 533 | 0, 0, 0, 0, // geometry | ||
| 534 | 0, // parent | ||
| 535 | 0, // menu handle | ||
| 536 | hi, // application | ||
| 537 | 0); // windows creation data. | ||
| 538 | #endif | ||
| 514 | wc.lpszClassName, // window name | ||
| 515 | 0, // style | ||
| 516 | 0, 0, 0, 0, // geometry | ||
| 517 | 0, // parent | ||
| 518 | 0, // menu handle | ||
| 519 | qWinAppInst(), // application | ||
| 520 | 0); // windows creation data. | ||
| 539 | 521 | ||
| 540 | |||
| 541 | 522 | #ifdef GWLP_USERDATA | |
| 542 | SetWindowLongPtrA(wnd, GWLP_USERDATA, (LONG_PTR)eventDispatcher); | ||
| 523 | SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)eventDispatcher); | ||
| 543 | 524 | #else | |
| 544 | SetWindowLongA(wnd, GWL_USERDATA, (LONG)eventDispatcher); | ||
| 525 | SetWindowLong(wnd, GWL_USERDATA, (LONG)eventDispatcher); | ||
| 545 | 526 | #endif | |
| 546 | 527 | ||
| 547 | 528 | if (!wnd) { | |
| … | … | ||
| 671 | 671 | haveMessage = true; | |
| 672 | 672 | msg = d->queuedSocketEvents.takeFirst(); | |
| 673 | 673 | } else { | |
| 674 | haveMessage = winPeekMessage(&msg, 0, 0, 0, PM_REMOVE); | ||
| 674 | haveMessage = PeekMessage(&msg, 0, 0, 0, PM_REMOVE); | ||
| 675 | 675 | if (haveMessage && (flags & QEventLoop::ExcludeUserInputEvents) | |
| 676 | 676 | && ((msg.message >= WM_KEYFIRST | |
| 677 | 677 | && msg.message <= WM_KEYLAST) | |
| … | … | ||
| 719 | 719 | ||
| 720 | 720 | if (!filterEvent(&msg)) { | |
| 721 | 721 | TranslateMessage(&msg); | |
| 722 | QT_WA({ | ||
| 723 | DispatchMessage(&msg); | ||
| 724 | } , { | ||
| 725 | DispatchMessageA(&msg); | ||
| 726 | }); | ||
| 722 | DispatchMessage(&msg); | ||
| 727 | 723 | } | |
| 728 | 724 | } else if (waitRet >= WAIT_OBJECT_0 && waitRet < WAIT_OBJECT_0 + nCount) { | |
| 729 | 725 | d->activateEventNotifier(d->winEventNotifierList.at(waitRet - WAIT_OBJECT_0)); | |
| … | … | ||
| 758 | 758 | bool QEventDispatcherWin32::hasPendingEvents() | |
| 759 | 759 | { | |
| 760 | 760 | MSG msg; | |
| 761 | return qGlobalPostedEventsCount() || winPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); | ||
| 761 | return qGlobalPostedEventsCount() || PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); | ||
| 762 | 762 | } | |
| 763 | 763 | ||
| 764 | 764 | void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) |
|   | |||
| 108 | 108 | return 1; | |
| 109 | 109 | } | |
| 110 | 110 | ||
| 111 | int qt_wince__waccess( const WCHAR *path, int pmode ) | ||
| 111 | int qt_wince__waccess( const wchar_t *path, int pmode ) | ||
| 112 | 112 | { | |
| 113 | 113 | DWORD res = GetFileAttributes( path ); | |
| 114 | 114 | if ( 0xFFFFFFFF == res ) | |
| … | … | ||
| 118 | 118 | return -1; | |
| 119 | 119 | ||
| 120 | 120 | if ( (pmode & X_OK) && !(res & FILE_ATTRIBUTE_DIRECTORY) ) { | |
| 121 | QString file = QString::fromUtf16(reinterpret_cast<const ushort *> (path)); | ||
| 121 | QString file = QString::fromWCharArray(path); | ||
| 122 | 122 | if ( !(file.endsWith(QString::fromLatin1(".exe")) || | |
| 123 | 123 | file.endsWith(QString::fromLatin1(".com"))) ) | |
| 124 | 124 | return -1; | |
| … | … | ||
| 130 | 130 | int qt_wince_open( const char *filename, int oflag, int pmode ) | |
| 131 | 131 | { | |
| 132 | 132 | QString fn( QString::fromLatin1(filename) ); | |
| 133 | return _wopen( (WCHAR*)fn.utf16(), oflag, pmode ); | ||
| 133 | return _wopen( (wchar_t*)fn.utf16(), oflag, pmode ); | ||
| 134 | 134 | } | |
| 135 | 135 | ||
| 136 | int qt_wince__wopen( const WCHAR *filename, int oflag, int /*pmode*/ ) | ||
| 136 | int qt_wince__wopen( const wchar_t *filename, int oflag, int /*pmode*/ ) | ||
| 137 | 137 | { | |
| 138 | WCHAR *flag; | ||
| 138 | wchar_t *flag; | ||
| 139 | 139 | ||
| 140 | 140 | if ( oflag & _O_APPEND ) { | |
| 141 | 141 | if ( oflag & _O_WRONLY ) { | |
| … | … | ||
| 290 | 290 | return _wchmod( reinterpret_cast<const wchar_t *> (QString::fromLatin1(file).utf16()), mode); | |
| 291 | 291 | } | |
| 292 | 292 | ||
| 293 | bool qt_wince__wchmod(const WCHAR *file, int mode) | ||
| 293 | bool qt_wince__wchmod(const wchar_t *file, int mode) | ||
| 294 | 294 | { | |
| 295 | 295 | // ### Does not work properly, what about just adding one property? | |
| 296 | 296 | if(mode&_S_IWRITE) { |
|   | |||
| 175 | 175 | extern int errno; | |
| 176 | 176 | ||
| 177 | 177 | int qt_wince__getdrive( void ); | |
| 178 | int qt_wince__waccess( const WCHAR *path, int pmode ); | ||
| 179 | int qt_wince__wopen( const WCHAR *filename, int oflag, int pmode ); | ||
| 178 | int qt_wince__waccess( const wchar_t *path, int pmode ); | ||
| 179 | int qt_wince__wopen( const wchar_t *filename, int oflag, int pmode ); | ||
| 180 | 180 | long qt_wince__lseek( int handle, long offset, int origin ); | |
| 181 | 181 | int qt_wince__read( int handle, void *buffer, unsigned int count ); | |
| 182 | 182 | int qt_wince__write( int handle, const void *buffer, unsigned int count ); | |
| … | … | ||
| 204 | 204 | #endif | |
| 205 | 205 | ||
| 206 | 206 | bool qt_wince__chmod(const char *file, int mode); | |
| 207 | bool qt_wince__wchmod(const WCHAR *file, int mode); | ||
| 207 | bool qt_wince__wchmod(const wchar_t *file, int mode); | ||
| 208 | 208 | ||
| 209 | 209 | #pragma warning(disable: 4273) | |
| 210 | 210 | HANDLE qt_wince_CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE); |
|   | |||
| 106 | 106 | return false; | |
| 107 | 107 | } | |
| 108 | 108 | #ifndef Q_OS_WINCE | |
| 109 | QT_WA({ | ||
| 110 | hand = OpenFileMappingW(FILE_MAP_ALL_ACCESS, false, (TCHAR*)safeKey.utf16()); | ||
| 111 | }, { | ||
| 112 | hand = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, safeKey.toLocal8Bit().constData()); | ||
| 113 | }); | ||
| 109 | hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)safeKey.utf16()); | ||
| 114 | 110 | #else | |
| 115 | 111 | // This works for opening a mapping too, but always opens it with read/write access in | |
| 116 | 112 | // attach as it seems. | |
| 117 | hand = CreateFileMappingW(INVALID_HANDLE_VALUE, | ||
| 118 | 0, PAGE_READWRITE, 0, 0, (TCHAR*)safeKey.utf16()); | ||
| 113 | hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)safeKey.utf16()); | ||
| 119 | 114 | #endif | |
| 120 | 115 | if (!hand) { | |
| 121 | 116 | setErrorString(function); | |
| … | … | ||
| 143 | 143 | } | |
| 144 | 144 | ||
| 145 | 145 | // Create the file mapping. | |
| 146 | QT_WA( { | ||
| 147 | hand = CreateFileMappingW(INVALID_HANDLE_VALUE, | ||
| 148 | 0, PAGE_READWRITE, 0, size, (TCHAR*)safeKey.utf16()); | ||
| 149 | }, { | ||
| 150 | hand = CreateFileMappingA(INVALID_HANDLE_VALUE, | ||
| 151 | 0, PAGE_READWRITE, 0, size, safeKey.toLocal8Bit().constData()); | ||
| 152 | } ); | ||
| 146 | hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)safeKey.utf16()); | ||
| 153 | 147 | setErrorString(function); | |
| 154 | 148 | ||
| 155 | 149 | // hand is valid when it already exists unlike unix so explicitly check |
|   | |||
| 87 | 87 | // Create it if it doesn't already exists. | |
| 88 | 88 | if (semaphore == 0) { | |
| 89 | 89 | QString safeName = makeKeyFileName(); | |
| 90 | QT_WA({ | ||
| 91 | semaphore = CreateSemaphoreW(0, initialValue, MAXLONG, (TCHAR*)safeName.utf16()); | ||
| 92 | }, { | ||
| 93 | semaphore = CreateSemaphoreA(0, initialValue, MAXLONG, safeName.toLocal8Bit().constData()); | ||
| 94 | }); | ||
| 90 | semaphore = CreateSemaphore(0, initialValue, MAXLONG, (wchar_t*)safeName.utf16()); | ||
| 95 | 91 | if (semaphore == NULL) | |
| 96 | 92 | setErrorString(QLatin1String("QSystemSemaphore::handle")); | |
| 97 | 93 | } |
|   | |||
| 103 | 103 | ||
| 104 | 104 | Note that QTimer's accuracy depends on the underlying operating | |
| 105 | 105 | system and hardware. Most platforms support an accuracy of | |
| 106 | 1 millisecond, but Windows 98 supports only 55. If Qt is | ||
| 107 | unable to deliver the requested number of timer clicks, it will | ||
| 108 | silently discard some. | ||
| 106 | 1 millisecond. If Qt is unable to deliver the requested number of | ||
| 107 | timer clicks, it will silently discard some. | ||
| 109 | 108 | ||
| 110 | 109 | An alternative to using QTimer is to call QObject::startTimer() | |
| 111 | 110 | for your object and reimplement the QObject::timerEvent() event |
|   | |||
| 623 | 623 | #endif | |
| 624 | 624 | if (!pHnd) { | |
| 625 | 625 | #ifdef Q_OS_WIN | |
| 626 | QT_WA({ | ||
| 627 | hTempModule = ::LoadLibraryExW((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, DONT_RESOLVE_DLL_REFERENCES); | ||
| 628 | } , { | ||
| 629 | temporary_load = load_sys(); | ||
| 630 | }); | ||
| 626 | hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, DONT_RESOLVE_DLL_REFERENCES); | ||
| 631 | 627 | #else | |
| 632 | 628 | temporary_load = load_sys(); | |
| 633 | 629 | #endif | |
| … | … | ||
| 637 | 637 | QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule | |
| 638 | 638 | ? (QtPluginQueryVerificationDataFunction) | |
| 639 | 639 | #ifdef Q_OS_WINCE | |
| 640 | ::GetProcAddressW(hTempModule, L"qt_plugin_query_verification_data") | ||
| 640 | ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data") | ||
| 641 | 641 | #else | |
| 642 | 642 | ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data") | |
| 643 | 643 | #endif |
|   | |||
| 67 | 67 | ||
| 68 | 68 | //avoid 'Bad Image' message box | |
| 69 | 69 | UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); | |
| 70 | QT_WA({ | ||
| 71 | pHnd = LoadLibraryW((TCHAR*)QDir::toNativeSeparators(attempt).utf16()); | ||
| 72 | } , { | ||
| 73 | pHnd = LoadLibraryA(QFile::encodeName(QDir::toNativeSeparators(attempt)).data()); | ||
| 74 | }); | ||
| 75 | |||
| 70 | pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16()); | ||
| 71 | |||
| 76 | 72 | if (pluginState != IsAPlugin) { | |
| 77 | 73 | #if defined(Q_OS_WINCE) | |
| 78 | 74 | if (!pHnd && ::GetLastError() == ERROR_MOD_NOT_FOUND) { | |
| 79 | 75 | QString secondAttempt = fileName; | |
| 80 | QT_WA({ | ||
| 81 | pHnd = LoadLibraryW((TCHAR*)QDir::toNativeSeparators(secondAttempt).utf16()); | ||
| 82 | } , { | ||
| 83 | pHnd = LoadLibraryA(QFile::encodeName(QDir::toNativeSeparators(secondAttempt)).data()); | ||
| 84 | }); | ||
| 76 | pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(secondAttempt).utf16()); | ||
| 85 | 77 | } | |
| 86 | 78 | #endif | |
| 87 | 79 | if (!pHnd && ::GetLastError() == ERROR_MOD_NOT_FOUND) { | |
| 88 | 80 | attempt += QLatin1String(".dll"); | |
| 89 | QT_WA({ | ||
| 90 | pHnd = LoadLibraryW((TCHAR*)QDir::toNativeSeparators(attempt).utf16()); | ||
| 91 | } , { | ||
| 92 | pHnd = LoadLibraryA(QFile::encodeName(QDir::toNativeSeparators(attempt)).data()); | ||
| 93 | }); | ||
| 81 | pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16()); | ||
| 94 | 82 | } | |
| 95 | 83 | } | |
| 96 | 84 | ||
| … | … | ||
| 88 | 88 | } | |
| 89 | 89 | if (pHnd) { | |
| 90 | 90 | errorString.clear(); | |
| 91 | QT_WA({ | ||
| 92 | TCHAR buffer[MAX_PATH + 1]; | ||
| 93 | ::GetModuleFileNameW(pHnd, buffer, MAX_PATH); | ||
| 94 | attempt = QString::fromUtf16(reinterpret_cast<const ushort *>(&buffer)); | ||
| 95 | }, { | ||
| 96 | char buffer[MAX_PATH + 1]; | ||
| 97 | ::GetModuleFileNameA(pHnd, buffer, MAX_PATH); | ||
| 98 | attempt = QString::fromLocal8Bit(buffer); | ||
| 99 | }); | ||
| 91 | |||
| 92 | wchar_t buffer[MAX_PATH]; | ||
| 93 | ::GetModuleFileName(pHnd, buffer, MAX_PATH); | ||
| 94 | attempt = QString::fromWCharArray(buffer); | ||
| 95 | |||
| 100 | 96 | const QDir dir = QFileInfo(fileName).dir(); | |
| 101 | 97 | const QString realfilename = attempt.mid(attempt.lastIndexOf(QLatin1Char('\\')) + 1); | |
| 102 | 98 | if (dir.path() == QLatin1String(".")) |
|   | |||
| 50 | 50 | QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode) | |
| 51 | 51 | : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0) | |
| 52 | 52 | { | |
| 53 | if (QSysInfo::WindowsVersion == 0) { | ||
| 54 | // mutex was created before initializing WindowsVersion. this | ||
| 55 | // can happen when creating the resource file engine handler, | ||
| 56 | // for example. try again with just the A version | ||
| 57 | #ifdef Q_OS_WINCE | ||
| 58 | event = CreateEventW(0, FALSE, FALSE, 0); | ||
| 59 | #else | ||
| 60 | event = CreateEventA(0, FALSE, FALSE, 0); | ||
| 61 | #endif | ||
| 62 | } else { | ||
| 63 | event = QT_WA_INLINE(CreateEventW(0, FALSE, FALSE, 0), | ||
| 64 | CreateEventA(0, FALSE, FALSE, 0)); | ||
| 65 | } | ||
| 53 | event = CreateEvent(0, FALSE, FALSE, 0); | ||
| 66 | 54 | if (!event) | |
| 67 | 55 | qWarning("QMutexPrivate::QMutexPrivate: Cannot create event"); | |
| 68 | 56 | } |
|   | |||
| 163 | 163 | // Start watcher thread if it is not already running. | |
| 164 | 164 | if (qt_adopted_thread_watcher_handle == 0) { | |
| 165 | 165 | if (qt_adopted_thread_wakeup == 0) { | |
| 166 | qt_adopted_thread_wakeup = QT_WA_INLINE(CreateEventW(0, false, false, 0), | ||
| 167 | CreateEventA(0, false, false, 0)); | ||
| 166 | qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0); | ||
| 168 | 167 | qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup); | |
| 169 | 168 | } | |
| 170 | 169 | ||
| … | … | ||
| 363 | 363 | void QThread::yieldCurrentThread() | |
| 364 | 364 | { | |
| 365 | 365 | #ifndef Q_OS_WINCE | |
| 366 | if (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) | ||
| 367 | SwitchToThread(); | ||
| 368 | else | ||
| 366 | SwitchToThread(); | ||
| 367 | #else | ||
| 368 | ::Sleep(0); | ||
| 369 | 369 | #endif | |
| 370 | ::Sleep(0); | ||
| 371 | 370 | } | |
| 372 | 371 | ||
| 373 | 372 | void QThread::sleep(unsigned long secs) | |
| … | … | ||
| 417 | 417 | return; | |
| 418 | 418 | } | |
| 419 | 419 | ||
| 420 | // Since Win 9x will have problems if the priority is idle or time critical | ||
| 421 | // we have to use the closest one instead | ||
| 422 | 420 | int prio; | |
| 423 | 421 | d->priority = priority; | |
| 424 | 422 | switch (d->priority) { | |
| 425 | 423 | case IdlePriority: | |
| 426 | if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { | ||
| 427 | prio = THREAD_PRIORITY_LOWEST; | ||
| 428 | } else { | ||
| 429 | prio = THREAD_PRIORITY_IDLE; | ||
| 430 | } | ||
| 424 | prio = THREAD_PRIORITY_IDLE; | ||
| 431 | 425 | break; | |
| 432 | 426 | ||
| 433 | 427 | case LowestPriority: | |
| … | … | ||
| 445 | 445 | break; | |
| 446 | 446 | ||
| 447 | 447 | case TimeCriticalPriority: | |
| 448 | if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { | ||
| 449 | prio = THREAD_PRIORITY_HIGHEST; | ||
| 450 | } else { | ||
| 451 | prio = THREAD_PRIORITY_TIME_CRITICAL; | ||
| 452 | } | ||
| 448 | prio = THREAD_PRIORITY_TIME_CRITICAL; | ||
| 453 | 449 | break; | |
| 454 | 450 | ||
| 455 | 451 | case InheritPriority: | |
| … | … | ||
| 551 | 551 | ||
| 552 | 552 | // copied from start() with a few modifications: | |
| 553 | 553 | ||
| 554 | // Since Win 9x will have problems if the priority is idle or time critical | ||
| 555 | // we have to use the closest one instead | ||
| 556 | 554 | int prio; | |
| 557 | 555 | d->priority = priority; | |
| 558 | 556 | switch (d->priority) { | |
| 559 | 557 | case IdlePriority: | |
| 560 | if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { | ||
| 561 | prio = THREAD_PRIORITY_LOWEST; | ||
| 562 | } else { | ||
| 563 | prio = THREAD_PRIORITY_IDLE; | ||
| 564 | } | ||
| 558 | prio = THREAD_PRIORITY_IDLE; | ||
| 565 | 559 | break; | |
| 566 | 560 | ||
| 567 | 561 | case LowestPriority: | |
| … | … | ||
| 579 | 579 | break; | |
| 580 | 580 | ||
| 581 | 581 | case TimeCriticalPriority: | |
| 582 | if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { | ||
| 583 | prio = THREAD_PRIORITY_HIGHEST; | ||
| 584 | } else { | ||
| 585 | prio = THREAD_PRIORITY_TIME_CRITICAL; | ||
| 586 | } | ||
| 582 | prio = THREAD_PRIORITY_TIME_CRITICAL; | ||
| 587 | 583 | break; | |
| 588 | 584 | ||
| 589 | 585 | case InheritPriority: |
|   | |||
| 64 | 64 | public: | |
| 65 | 65 | inline QWaitConditionEvent() : priority(0), wokenUp(false) | |
| 66 | 66 | { | |
| 67 | QT_WA ({ | ||
| 68 | event = CreateEvent(NULL, TRUE, FALSE, NULL); | ||
| 69 | }, { | ||
| 70 | event = CreateEventA(NULL, TRUE, FALSE, NULL); | ||
| 71 | }); | ||
| 67 | event = CreateEvent(NULL, TRUE, FALSE, NULL); | ||
| 72 | 68 | } | |
| 73 | 69 | inline ~QWaitConditionEvent() { CloseHandle(event); } | |
| 74 | 70 | int priority; |
src/corelib/tools/qdatetime.cpp
(3 / 10)
|   | |||
| 2503 | 2503 | buf += QLatin1Char(' '); | |
| 2504 | 2504 | buf += QString::number(d->date.day()); | |
| 2505 | 2505 | #else | |
| 2506 | QString winstr; | ||
| 2507 | QT_WA({ | ||
| 2508 | TCHAR out[255]; | ||
| 2509 | GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255); | ||
| 2510 | winstr = QString::fromUtf16((ushort*)out); | ||
| 2511 | } , { | ||
| 2512 | char out[255]; | ||
| 2513 | GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ILDATE, (char*)&out, 255); | ||
| 2514 | winstr = QString::fromLocal8Bit(out); | ||
| 2515 | }); | ||
| 2506 | wchar_t out[255]; | ||
| 2507 | GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255); | ||
| 2508 | QString winstr = QString::fromWCharArray(out); | ||
| 2516 | 2509 | switch (winstr.toInt()) { | |
| 2517 | 2510 | case 1: | |
| 2518 | 2511 | buf = d->date.shortDayName(d->date.dayOfWeek()); |
src/corelib/tools/qlocale.cpp
(36 / 97)
|   | |||
| 386 | 386 | ||
| 387 | 387 | static QString getWinLocaleInfo(LCTYPE type) | |
| 388 | 388 | { | |
| 389 | int cnt = 0; | ||
| 390 | |||
| 391 | 389 | LCID id = GetUserDefaultLCID(); | |
| 390 | int cnt = GetLocaleInfo(id, type, 0, 0) * 2; | ||
| 392 | 391 | ||
| 393 | QT_WA({ | ||
| 394 | cnt = GetLocaleInfoW(id, type, 0, 0)*2; | ||
| 395 | } , { | ||
| 396 | cnt = GetLocaleInfoA(id, type, 0, 0); | ||
| 397 | }); | ||
| 398 | |||
| 399 | 392 | if (cnt == 0) { | |
| 400 | 393 | qWarning("QLocale: empty windows locale info (%d)", (int)type); | |
| 401 | 394 | return QString(); | |
| … | … | ||
| 396 | 396 | ||
| 397 | 397 | QByteArray buff(cnt, 0); | |
| 398 | 398 | ||
| 399 | QT_WA({ | ||
| 400 | cnt = GetLocaleInfoW(id, type, | ||
| 401 | reinterpret_cast<wchar_t*>(buff.data()), | ||
| 402 | buff.size()/2); | ||
| 403 | } , { | ||
| 404 | cnt = GetLocaleInfoA(id, type, | ||
| 405 | buff.data(), buff.size()); | ||
| 406 | }); | ||
| 399 | cnt = GetLocaleInfo(id, type, reinterpret_cast<wchar_t*>(buff.data()), buff.size() / 2); | ||
| 407 | 400 | ||
| 408 | 401 | if (cnt == 0) { | |
| 409 | 402 | qWarning("QLocale: empty windows locale info (%d)", (int)type); | |
| 410 | 403 | return QString(); | |
| 411 | 404 | } | |
| 412 | 405 | ||
| 413 | QString result; | ||
| 414 | QT_WA({ | ||
| 415 | result = QString::fromUtf16(reinterpret_cast<ushort*>(buff.data())); | ||
| 416 | } , { | ||
| 417 | result = QString::fromLocal8Bit(buff.data()); | ||
| 418 | }); | ||
| 419 | return result; | ||
| 406 | return QString::fromWCharArray(reinterpret_cast<const wchar_t *>(buff.data())); | ||
| 420 | 407 | } | |
| 421 | 408 | ||
| 422 | 409 | QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT) | |
| … | … | ||
| 425 | 425 | } | |
| 426 | 426 | } | |
| 427 | 427 | ||
| 428 | if (QSysInfo::WindowsVersion == QSysInfo::WV_95 | ||
| 429 | || (QSysInfo::WindowsVersion & QSysInfo::WV_CE_based)) { | ||
| 430 | result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID()); | ||
| 431 | } else { | ||
| 432 | if (id == LOCALE_USER_DEFAULT) | ||
| 433 | id = GetUserDefaultLCID(); | ||
| 434 | QString resultuage = winIso639LangName(id); | ||
| 435 | QString country = winIso3116CtryName(id); | ||
| 436 | result = resultuage.toLatin1(); | ||
| 437 | if (!country.isEmpty()) { | ||
| 438 | result += '_'; | ||
| 439 | result += country.toLatin1(); | ||
| 440 | } | ||
| 428 | #if defined(Q_OS_WINCE) | ||
| 429 | result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID()); | ||
| 430 | #else | ||
| 431 | if (id == LOCALE_USER_DEFAULT) | ||
| 432 | id = GetUserDefaultLCID(); | ||
| 433 | QString resultuage = winIso639LangName(id); | ||
| 434 | QString country = winIso3116CtryName(id); | ||
| 435 | result = resultuage.toLatin1(); | ||
| 436 | if (!country.isEmpty()) { | ||
| 437 | result += '_'; | ||
| 438 | result += country.toLatin1(); | ||
| 441 | 439 | } | |
| 440 | #endif | ||
| 442 | 441 | ||
| 443 | 442 | return result; | |
| 444 | 443 | } | |
| … | … | ||
| 523 | 523 | ||
| 524 | 524 | LCID id = GetUserDefaultLCID(); | |
| 525 | 525 | ||
| 526 | QT_WA({ | ||
| 527 | TCHAR buf[255]; | ||
| 528 | if (GetDateFormatW(id, flags, &st, 0, buf, 255)) | ||
| 529 | return QString::fromUtf16((ushort*)buf); | ||
| 530 | } , { | ||
| 531 | char buf[255]; | ||
| 532 | if (GetDateFormatA(id, flags, &st, 0, (char*)&buf, 255)) | ||
| 533 | return QString::fromLocal8Bit(buf); | ||
| 534 | }); | ||
| 526 | wchar_t buf[255]; | ||
| 527 | if (GetDateFormat(id, flags, &st, 0, buf, 255)) | ||
| 528 | return QString::fromWCharArray(buf); | ||
| 535 | 529 | ||
| 536 | 530 | return QString(); | |
| 537 | 531 | } | |
| … | … | ||
| 542 | 542 | DWORD flags = 0; | |
| 543 | 543 | LCID id = GetUserDefaultLCID(); | |
| 544 | 544 | ||
| 545 | QT_WA({ | ||
| 546 | TCHAR buf[255]; | ||
| 547 | if (GetTimeFormatW(id, flags, &st, 0, buf, 255)) | ||
| 548 | return QString::fromUtf16((ushort*)buf); | ||
| 549 | } , { | ||
| 550 | char buf[255]; | ||
| 551 | if (GetTimeFormatA(id, flags, &st, 0, (char*)&buf, 255)) | ||
| 552 | return QString::fromLocal8Bit(buf); | ||
| 553 | }); | ||
| 545 | wchar_t buf[255]; | ||
| 546 | if (GetTimeFormat(id, flags, &st, 0, buf, 255)) | ||
| 547 | return QString::fromWCharArray(buf); | ||
| 554 | 548 | ||
| 555 | 549 | return QString(); | |
| 556 | 550 | } | |
| … | … | ||
| 593 | 593 | static QLocale::MeasurementSystem winSystemMeasurementSystem() | |
| 594 | 594 | { | |
| 595 | 595 | LCID id = GetUserDefaultLCID(); | |
| 596 | TCHAR output[2]; | ||
| 596 | wchar_t output[2]; | ||
| 597 | 597 | ||
| 598 | 598 | if (GetLocaleInfo(id, LOCALE_IMEASURE, output, 2)) { | |
| 599 | QString iMeasure = QT_WA_INLINE( | ||
| 600 | QString::fromUtf16(reinterpret_cast<ushort*>(output)), | ||
| 601 | QString::fromLocal8Bit(reinterpret_cast<char*>(output))); | ||
| 599 | QString iMeasure = QString::fromWCharArray(output); | ||
| 602 | 600 | if (iMeasure == QLatin1String("1")) { | |
| 603 | 601 | return QLocale::ImperialSystem; | |
| 604 | 602 | } | |
| … | … | ||
| 608 | 608 | static QString winSystemAMText() | |
| 609 | 609 | { | |
| 610 | 610 | LCID id = GetUserDefaultLCID(); | |
| 611 | TCHAR output[15]; // maximum length including terminating zero character for Win2003+ | ||
| 611 | wchar_t output[15]; // maximum length including terminating zero character for Win2003+ | ||
| 612 | 612 | ||
| 613 | 613 | if (GetLocaleInfo(id, LOCALE_S1159, output, 15)) { | |
| 614 | return QT_WA_INLINE( | ||
| 615 | QString::fromUtf16(reinterpret_cast<ushort*>(output)), | ||
| 616 | QString::fromLocal8Bit(reinterpret_cast<char*>(output))); | ||
| 614 | return QString::fromWCharArray(output); | ||
| 617 | 615 | } | |
| 618 | 616 | ||
| 619 | 617 | return QString(); | |
| … | … | ||
| 620 | 620 | static QString winSystemPMText() | |
| 621 | 621 | { | |
| 622 | 622 | LCID id = GetUserDefaultLCID(); | |
| 623 | TCHAR output[15]; // maximum length including terminating zero character for Win2003+ | ||
| 623 | wchar_t output[15]; // maximum length including terminating zero character for Win2003+ | ||
| 624 | 624 | ||
| 625 | 625 | if (GetLocaleInfo(id, LOCALE_S2359, output, 15)) { | |
| 626 | return QT_WA_INLINE( | ||
| 627 | QString::fromUtf16(reinterpret_cast<ushort*>(output)), | ||
| 628 | QString::fromLocal8Bit(reinterpret_cast<char*>(output))); | ||
| 626 | return QString::fromWCharArray(output); | ||
| 629 | 627 | } | |
| 630 | 628 | ||
| 631 | 629 | return QString(); | |
| … | … | ||
| 727 | 727 | return QVariant(); | |
| 728 | 728 | } | |
| 729 | 729 | ||
| 730 | /* Win95 doesn't have a function to return the ISO lang/country name of the user's locale. | ||
| 731 | Instead it can return a "Windows code". This maps windows codes to ISO country names. */ | ||
| 732 | |||
| 733 | 730 | struct WindowsToISOListElt { | |
| 734 | 731 | ushort windows_code; | |
| 735 | 732 | char iso_name[6]; | |
| … | … | ||
| 882 | 882 | // Windows returns the wrong ISO639 for some languages, we need to detect them here using | |
| 883 | 883 | // the language code | |
| 884 | 884 | QString lang_code; | |
| 885 | QT_WA({ | ||
| 886 | TCHAR out[256]; | ||
| 887 | if (GetLocaleInfoW(id, LOCALE_ILANGUAGE, out, 255)) | ||
| 888 | lang_code = QString::fromUtf16((ushort*)out); | ||
| 889 | } , { | ||
| 890 | char out[256]; | ||
| 891 | if (GetLocaleInfoA(id, LOCALE_ILANGUAGE, out, 255)) | ||
| 892 | lang_code = QString::fromLocal8Bit(out); | ||
| 893 | }); | ||
| 885 | wchar_t out[256]; | ||
| 886 | if (GetLocaleInfo(id, LOCALE_ILANGUAGE, out, 255)) | ||
| 887 | lang_code = QString::fromWCharArray(out); | ||
| 894 | 888 | ||
| 895 | 889 | if (!lang_code.isEmpty()) { | |
| 896 | 890 | const char *endptr; | |
| … | … | ||
| 906 | 906 | return result; | |
| 907 | 907 | ||
| 908 | 908 | // not one of the problematic languages - do the usual lookup | |
| 909 | QT_WA({ | ||
| 910 | TCHAR out[256]; | ||
| 911 | if (GetLocaleInfoW(id, LOCALE_SISO639LANGNAME , out, 255)) | ||
| 912 | result = QString::fromUtf16((ushort*)out); | ||
| 913 | } , { | ||
| 914 | char out[256]; | ||
| 915 | if (GetLocaleInfoA(id, LOCALE_SISO639LANGNAME, out, 255)) | ||
| 916 | result = QString::fromLocal8Bit(out); | ||
| 917 | }); | ||
| 909 | if (GetLocaleInfo(id, LOCALE_SISO639LANGNAME , out, 255)) | ||
| 910 | result = QString::fromWCharArray(out); | ||
| 918 | 911 | ||
| 919 | 912 | return result; | |
| 920 | 913 | } | |
| … | … | ||
| 916 | 916 | { | |
| 917 | 917 | QString result; | |
| 918 | 918 | ||
| 919 | QT_WA({ | ||
| 920 | TCHAR out[256]; | ||
| 921 | if (GetLocaleInfoW(id, LOCALE_SISO3166CTRYNAME, out, 255)) | ||
| 922 | result = QString::fromUtf16((ushort*)out); | ||
| 923 | } , { | ||
| 924 | char out[256]; | ||
| 925 | if (GetLocaleInfoA(id, LOCALE_SISO3166CTRYNAME, out, 255)) | ||
| 926 | result = QString::fromLocal8Bit(out); | ||
| 927 | }); | ||
| 919 | wchar_t out[256]; | ||
| 920 | if (GetLocaleInfo(id, LOCALE_SISO3166CTRYNAME, out, 255)) | ||
| 921 | result = QString::fromWCharArray(out); | ||
| 928 | 922 | ||
| 929 | 923 | return result; | |
| 930 | 924 | } | |
| … | … | ||
| 2628 | 2628 | DWORD res = GetTimeZoneInformation(&info); | |
| 2629 | 2629 | if (res == TIME_ZONE_ID_UNKNOWN) | |
| 2630 | 2630 | return QString(); | |
| 2631 | return QString::fromUtf16(reinterpret_cast<const ushort *> (info.StandardName)); | ||
| 2631 | return QString::fromWCharArray(info.StandardName); | ||
| 2632 | 2632 | #elif defined(Q_OS_WIN) | |
| 2633 | 2633 | _tzset(); | |
| 2634 | 2634 | # if defined(_MSC_VER) && _MSC_VER >= 1400 |
src/corelib/tools/qstring.cpp
(6 / 20)
|   | |||
| 3714 | 3714 | BOOL used_def; | |
| 3715 | 3715 | QByteArray mb(4096, 0); | |
| 3716 | 3716 | int len; | |
| 3717 | while (!(len=WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)ch, uclen, | ||
| 3717 | while (!(len=WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)ch, uclen, | ||
| 3718 | 3718 | mb.data(), mb.size()-1, 0, &used_def))) | |
| 3719 | 3719 | { | |
| 3720 | 3720 | int r = GetLastError(); | |
| 3721 | 3721 | if (r == ERROR_INSUFFICIENT_BUFFER) { | |
| 3722 | 3722 | mb.resize(1+WideCharToMultiByte(CP_ACP, 0, | |
| 3723 | (const WCHAR*)ch, uclen, | ||
| 3723 | (const wchar_t*)ch, uclen, | ||
| 3724 | 3724 | 0, 0, 0, &used_def)); | |
| 3725 | 3725 | // and try again... | |
| 3726 | 3726 | } else { | |
| … | … | ||
| 3741 | 3741 | if (!mb || !mblen) | |
| 3742 | 3742 | return QString(); | |
| 3743 | 3743 | const int wclen_auto = 4096; | |
| 3744 | WCHAR wc_auto[wclen_auto]; | ||
| 3744 | wchar_t wc_auto[wclen_auto]; | ||
| 3745 | 3745 | int wclen = wclen_auto; | |
| 3746 | WCHAR *wc = wc_auto; | ||
| 3746 | wchar_t *wc = wc_auto; | ||
| 3747 | 3747 | int len; | |
| 3748 | 3748 | while (!(len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, | |
| 3749 | 3749 | mb, mblen, wc, wclen))) | |
| … | … | ||
| 3756 | 3756 | } else { | |
| 3757 | 3757 | wclen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, | |
| 3758 | 3758 | mb, mblen, 0, 0); | |
| 3759 | wc = new WCHAR[wclen]; | ||
| 3759 | wc = new wchar_t[wclen]; | ||
| 3760 | 3760 | // and try again... | |
| 3761 | 3761 | } | |
| 3762 | 3762 | } else { | |
| … | … | ||
| 3799 | 3799 | return QString(); | |
| 3800 | 3800 | if (size == 0 || (!*str && size < 0)) | |
| 3801 | 3801 | return QLatin1String(""); | |
| 3802 | #if defined(Q_OS_WIN32) | ||
| 3803 | if(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { | ||
| 3804 | return qt_winMB2QString(str, size); | ||
| 3805 | } | ||
| 3806 | #endif | ||
| 3807 | 3802 | #if !defined(QT_NO_TEXTCODEC) | |
| 3808 | 3803 | if (size < 0) | |
| 3809 | 3804 | size = qstrlen(str); | |
| … | … | ||
| 4692 | 4692 | return ucstrcmp(data1, length1, data2, length2); | |
| 4693 | 4693 | ||
| 4694 | 4694 | #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) | |
| 4695 | int res; | ||
| 4696 | QT_WA({ | ||
| 4697 | const TCHAR* s1 = (TCHAR*)data1; | ||
| 4698 | const TCHAR* s2 = (TCHAR*)data2; | ||
| 4699 | res = CompareStringW(GetUserDefaultLCID(), 0, s1, length1, s2, length2); | ||
| 4700 | } , { | ||
| 4701 | QByteArray s1 = toLocal8Bit_helper(data1, length1); | ||
| 4702 | QByteArray s2 = toLocal8Bit_helper(data2, length2); | ||
| 4703 | res = CompareStringA(GetUserDefaultLCID(), 0, s1.data(), s1.length(), s2.data(), s2.length()); | ||
| 4704 | }); | ||
| 4695 | int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2); | ||
| 4705 | 4696 | ||
| 4706 | 4697 | switch (res) { | |
| 4707 | 4698 | case CSTR_LESS_THAN: |

