OLD | NEW |
1 #include "stdafx.h" | 1 #include <Windows.h> |
| 2 #include <ShlObj.h> |
| 3 |
2 #include "Utils.h" | 4 #include "Utils.h" |
3 | 5 |
4 namespace | 6 namespace |
5 { | 7 { |
6 static std::wstring appDataPath; | 8 std::wstring appDataPath; |
7 | 9 |
8 bool IsWindowsVistaOrLater() | 10 bool IsWindowsVistaOrLater() |
9 { | 11 { |
10 OSVERSIONINFOEX osvi; | 12 OSVERSIONINFOEX osvi; |
11 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); | 13 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
12 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); | 14 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
13 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi)); | 15 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi)); |
14 return osvi.dwMajorVersion >= 6; | 16 return osvi.dwMajorVersion >= 6; |
15 } | 17 } |
16 } | 18 } |
(...skipping 10 matching lines...) Expand all Loading... |
27 appDataPath.assign(pathBuffer); | 29 appDataPath.assign(pathBuffer); |
28 CoTaskMemFree(pathBuffer); | 30 CoTaskMemFree(pathBuffer); |
29 } | 31 } |
30 else | 32 else |
31 { | 33 { |
32 std::auto_ptr<wchar_t> pathBuffer(new wchar_t[MAX_PATH]); | 34 std::auto_ptr<wchar_t> pathBuffer(new wchar_t[MAX_PATH]); |
33 if (!SHGetSpecialFolderPath(0, pathBuffer.get(), CSIDL_LOCAL_APPDATA, true
)) | 35 if (!SHGetSpecialFolderPath(0, pathBuffer.get(), CSIDL_LOCAL_APPDATA, true
)) |
34 throw std::runtime_error("Unable to find app data directory"); | 36 throw std::runtime_error("Unable to find app data directory"); |
35 appDataPath.assign(pathBuffer.get()); | 37 appDataPath.assign(pathBuffer.get()); |
36 } | 38 } |
37 appDataPath += L"\\AdblockPlus"; | 39 appDataPath += L"\\Adblock Plus for IE"; |
| 40 |
| 41 // Ignore errors here, this isn't a critical operation |
| 42 ::CreateDirectoryW(appDataPath.c_str(), NULL); |
38 } | 43 } |
39 return appDataPath; | 44 return appDataPath; |
40 } | 45 } |
OLD | NEW |