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