Skip to content

Commit 88c0a5f

Browse files
committed
Add PYTHONPATH/PYTHONHOME logic to cadabra2-cli.
1 parent 9b731ce commit 88c0a5f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

core/cadabra2-cli.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@
1616
#include "InstallPrefix.hh"
1717
#include "PreClean.hh"
1818

19+
#ifdef _WIN32
20+
21+
std::string getRegKey(const std::string& location, const std::string& name, bool system)
22+
{
23+
HKEY key;
24+
TCHAR value[1024];
25+
DWORD bufLen = 1024*sizeof(TCHAR);
26+
long ret;
27+
ret = RegOpenKeyExA(system?HKEY_LOCAL_MACHINE:HKEY_CURRENT_USER, location.c_str(), 0, KEY_QUERY_VALUE, &key);
28+
if( ret != ERROR_SUCCESS ){
29+
return std::string();
30+
}
31+
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
32+
RegCloseKey(key);
33+
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
34+
return std::string();
35+
}
36+
std::string stringValue = std::string(value, (size_t)bufLen - 1);
37+
size_t i = stringValue.length();
38+
while( i > 0 && stringValue[i-1] == '\0' ){
39+
--i;
40+
}
41+
return stringValue.substr(0,i);
42+
}
43+
44+
#endif
45+
1946
using namespace linenoise;
2047

2148
std::string replace_all(std::string const& original, std::string const& from, std::string const& to )

0 commit comments

Comments
 (0)