summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorl0calh05t <l0calh05t@gmx.net>2015-10-08 07:02:34 (GMT)
committerl0calh05t <l0calh05t@gmx.net>2015-10-08 07:02:34 (GMT)
commit022f160fa2dab744096a2fef6040164a40926dff (patch)
tree7a8df6511a7100a1c6833808a15b543e8e2a2a18 /src
parent743854127a5f57ef9495723373a4faaf276b2d54 (diff)
downloadcv2pdb-022f160fa2dab744096a2fef6040164a40926dff.zip
cv2pdb-022f160fa2dab744096a2fef6040164a40926dff.tar.gz
cv2pdb-022f160fa2dab744096a2fef6040164a40926dff.tar.bz2
fixes #11 (style adjustments)
Diffstat (limited to 'src')
-rw-r--r--src/mspdb.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/mspdb.cpp b/src/mspdb.cpp
index bde236d..fbb9434 100644
--- a/src/mspdb.cpp
+++ b/src/mspdb.cpp
@@ -45,17 +45,19 @@ void tryLoadLibrary(const char* mspdb)
modMsPdb = NULL;
}
+#if _M_X64
+#define KEY_OPEN_FLAGS KEY_QUERY_VALUE | KEY_WOW64_32KEY
+#else
+#define KEY_OPEN_FLAGS KEY_QUERY_VALUE
+#endif
+
bool getInstallDir(const char* version, char* installDir, DWORD size)
{
char key[260] = "SOFTWARE\\Microsoft\\";
strcat(key, version);
HKEY hkey;
- if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE
-#if _M_X64
- | KEY_WOW64_32KEY
-#endif
- , &hkey) != ERROR_SUCCESS)
+ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_OPEN_FLAGS, &hkey) != ERROR_SUCCESS)
return false;
bool rc = RegQueryValueExA(hkey, "InstallDir", 0, 0, (LPBYTE)installDir, &size) == ERROR_SUCCESS;
@@ -80,11 +82,11 @@ bool tryLoadMsPdb(const char* version, const char* mspdb, const char* path = 0)
}
#ifdef _M_X64
-#define MSPDB_DIR_NEW "..\\..\\VC\\bin\\amd64\\"
-#define MSPDB_DIR_OLD MSPDB_DIR_NEW
+#define BIN_DIR_GE_VS12 "..\\..\\VC\\bin\\amd64\\"
+#define BIN_DIR_LT_VS12 BIN_DIR_GE_VS12
#else
-#define MSPDB_DIR_NEW "..\\..\\VC\\bin\\"
-#define MSPDB_DIR_OLD 0
+#define BIN_DIR_GE_VS12 "..\\..\\VC\\bin\\"
+#define BIN_DIR_LT_VS12 0
#endif
void tryLoadMsPdb80(bool throughPath)
@@ -93,13 +95,13 @@ void tryLoadMsPdb80(bool throughPath)
tryLoadLibrary(mspdb80_dll);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VisualStudio\\9.0", mspdb80_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VisualStudio\\9.0", mspdb80_dll, BIN_DIR_LT_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VisualStudio\\8.0", mspdb80_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VisualStudio\\8.0", mspdb80_dll, BIN_DIR_LT_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VCExpress\\9.0", mspdb80_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VCExpress\\9.0", mspdb80_dll, BIN_DIR_LT_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VCExpress\\8.0", mspdb80_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VCExpress\\8.0", mspdb80_dll, BIN_DIR_LT_VS12);
}
void tryLoadMsPdb100(bool throughPath)
@@ -109,9 +111,9 @@ void tryLoadMsPdb100(bool throughPath)
if(throughPath)
modMsPdb = LoadLibraryA(mspdb100_dll);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VisualStudio\\10.0", mspdb100_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VisualStudio\\10.0", mspdb100_dll, BIN_DIR_LT_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VCExpress\\10.0", mspdb100_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VCExpress\\10.0", mspdb100_dll, BIN_DIR_LT_VS12);
if (modMsPdb)
mspdb::vsVersion = 10;
}
@@ -124,9 +126,9 @@ void tryLoadMsPdb110(bool throughPath)
if (throughPath)
modMsPdb = LoadLibraryA(mspdb110_dll);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VisualStudio\\11.0", mspdb110_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VisualStudio\\11.0", mspdb110_dll, BIN_DIR_LT_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VSWinExpress\\11.0", mspdb110_dll, MSPDB_DIR_OLD);
+ tryLoadMsPdb("VSWinExpress\\11.0", mspdb110_dll, BIN_DIR_LT_VS12);
if (modMsPdb)
mspdb::vsVersion = 11;
}
@@ -139,9 +141,9 @@ void tryLoadMsPdb120(bool throughPath)
if(throughPath)
modMsPdb = LoadLibraryA(mspdb120_dll);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VisualStudio\\12.0", mspdb120_dll, MSPDB_DIR_NEW);
+ tryLoadMsPdb("VisualStudio\\12.0", mspdb120_dll, BIN_DIR_GE_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VSWinExpress\\12.0", mspdb120_dll, MSPDB_DIR_NEW);
+ tryLoadMsPdb("VSWinExpress\\12.0", mspdb120_dll, BIN_DIR_GE_VS12);
if (modMsPdb)
mspdb::vsVersion = 12;
}
@@ -154,9 +156,9 @@ void tryLoadMsPdb140(bool throughPath)
if(throughPath)
modMsPdb = LoadLibraryA(mspdb140_dll);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VisualStudio\\14.0", mspdb140_dll, MSPDB_DIR_NEW);
+ tryLoadMsPdb("VisualStudio\\14.0", mspdb140_dll, BIN_DIR_GE_VS12);
if (!modMsPdb && !throughPath)
- tryLoadMsPdb("VSWinExpress\\14.0", mspdb140_dll, MSPDB_DIR_NEW);
+ tryLoadMsPdb("VSWinExpress\\14.0", mspdb140_dll, BIN_DIR_GE_VS12);
if (modMsPdb)
mspdb::vsVersion = 14;
}