aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-02-28 11:45:14 -0500
committerGavin Andresen <gavinandresen@gmail.com>2012-02-28 11:45:14 -0500
commit6dd5ae41ac7c31a74c27e7a15024be9284cd2476 (patch)
tree446b9f7f48439c5a892eb14cee7c8908e9c82828 /src
parentd8a80af84af77a5da00c988cb9d0d0dad7192509 (diff)
parent21ae37d215e4384369d8757def895f2b31426807 (diff)
Merge branch '2012_02_getspecialfolderpath_overflow' of https://github.com/laanwj/bitcoin
Diffstat (limited to 'src')
-rw-r--r--src/util.cpp43
1 files changed, 10 insertions, 33 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 88d70cd38f..1623fe84ef 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -787,46 +787,23 @@ void PrintExceptionContinue(std::exception* pex, const char* pszThread)
strMiscWarning = pszMessage;
}
-
-
-
-
-
-
-
#ifdef WIN32
-typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
-
string MyGetSpecialFolderPath(int nFolder, bool fCreate)
{
- char pszPath[MAX_PATH+100] = "";
-
- // SHGetSpecialFolderPath isn't always available on old Windows versions
- HMODULE hShell32 = LoadLibraryA("shell32.dll");
- if (hShell32)
+ char pszPath[MAX_PATH] = "";
+ if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate))
{
- PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =
- (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");
- if (pSHGetSpecialFolderPath)
- (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);
- FreeModule(hShell32);
+ return pszPath;
}
-
- // Backup option
- if (pszPath[0] == '\0')
+ else if (nFolder == CSIDL_STARTUP)
{
- if (nFolder == CSIDL_STARTUP)
- {
- strcpy(pszPath, getenv("USERPROFILE"));
- strcat(pszPath, "\\Start Menu\\Programs\\Startup");
- }
- else if (nFolder == CSIDL_APPDATA)
- {
- strcpy(pszPath, getenv("APPDATA"));
- }
+ return string(getenv("USERPROFILE")) + "\\Start Menu\\Programs\\Startup";
}
-
- return pszPath;
+ else if (nFolder == CSIDL_APPDATA)
+ {
+ return getenv("APPDATA");
+ }
+ return "";
}
#endif