mirror of https://github.com/BOINC/boinc.git
SS: On Windows, get paths to BOINC data and executable directories from Windows registry
svn path=/trunk/boinc/; revision=17256
This commit is contained in:
parent
ccca6db3d7
commit
0668305208
|
@ -370,6 +370,9 @@ void *CScreensaver::DataManagementProc()
|
|||
|
||||
SS_PHASE ss_phase = DEFAULT_SS_PHASE;
|
||||
bool switch_to_default_gfx = false;
|
||||
|
||||
char* default_ss_dir_path = NULL;
|
||||
char* default_data_dir_path = NULL;
|
||||
char full_path[1024];
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -390,10 +393,14 @@ void *CScreensaver::DataManagementProc()
|
|||
m_fGFXChangePeriod = GFX_CHANGE_PERIOD;
|
||||
|
||||
#ifdef __APPLE__
|
||||
char * default_ss_dir_path = "/Library/Application Support/BOINC Data";
|
||||
default_data_dir_path = "/Library/Application Support/BOINC Data";
|
||||
default_ss_dir_path = default_data_dir_path;
|
||||
#else
|
||||
// TODO: Obtain correct path to Windows default OpenGL screensaver executable
|
||||
char * default_ss_dir_path = "C:\\Program Files\\BOINC";
|
||||
UtilGetRegDirectoryStr(_T("INSTALLDIR"), &default_ss_dir_path);
|
||||
BOINCTRACE(_T("CScreensaver::DataManagementProc - default_ss_dir_path = '%s'\n"), default_ss_dir_path);
|
||||
retval = UtilGetRegDirectoryStr(_T("DATADIR"), &default_data_dir_path);
|
||||
BOINCTRACE(_T("CScreensaver::DataManagementProc - default_data_dir_path = '%s'\n"), default_data_dir_path);
|
||||
retval = 0;
|
||||
#endif
|
||||
strlcpy(full_path, default_ss_dir_path, sizeof(full_path));
|
||||
strlcat(full_path, PATH_SEPARATOR, sizeof(full_path));
|
||||
|
@ -411,7 +418,7 @@ void *CScreensaver::DataManagementProc()
|
|||
science_phase_start_time = dtime();
|
||||
}
|
||||
|
||||
GetDisplayPeriods(default_ss_dir_path);
|
||||
GetDisplayPeriods(default_data_dir_path);
|
||||
|
||||
while (true) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
@ -428,6 +435,12 @@ void *CScreensaver::DataManagementProc()
|
|||
previous_result_ptr = NULL;
|
||||
m_hGraphicsApplication = 0;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (default_ss_dir_path) free(default_ss_dir_path);
|
||||
default_ss_dir_path = NULL;
|
||||
if (default_data_dir_path) free(default_data_dir_path);
|
||||
default_data_dir_path = NULL;
|
||||
#endif
|
||||
return 0; // Exit the thread
|
||||
}
|
||||
|
||||
|
|
|
@ -666,6 +666,65 @@ int CScreensaver::UtilGetRegStartupStr(LPCTSTR name, LPTSTR str) {
|
|||
|
||||
|
||||
|
||||
// arguments: name: name of key, str: address of pointer to receive string
|
||||
// returns: int indicating error
|
||||
// function: gets string value in specified key in windows startup dir
|
||||
//
|
||||
int CScreensaver::UtilGetRegDirectoryStr(LPCTSTR name, char **dir_string) {
|
||||
//
|
||||
// Determine BOINCMgr Data Directory
|
||||
//
|
||||
LONG lReturnValue;
|
||||
HKEY hkSetupHive;
|
||||
LPTSTR lpszRegistryValue = NULL;
|
||||
DWORD dwSize = 0;
|
||||
|
||||
// change the current directory to the boinc data directory if it exists
|
||||
lReturnValue = RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
_T("SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup"),
|
||||
0,
|
||||
KEY_READ,
|
||||
&hkSetupHive
|
||||
);
|
||||
if (lReturnValue == ERROR_SUCCESS) {
|
||||
// How large does our buffer need to be?
|
||||
lReturnValue = RegQueryValueEx(
|
||||
hkSetupHive,
|
||||
name,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&dwSize
|
||||
);
|
||||
if (lReturnValue != ERROR_FILE_NOT_FOUND) {
|
||||
// Allocate the buffer space.
|
||||
lpszRegistryValue = (LPTSTR) malloc(dwSize);
|
||||
(*lpszRegistryValue) = NULL;
|
||||
|
||||
// Now get the data
|
||||
lReturnValue = RegQueryValueEx(
|
||||
hkSetupHive,
|
||||
name,
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)lpszRegistryValue,
|
||||
&dwSize
|
||||
);
|
||||
|
||||
// Store the root directory for later use.
|
||||
*dir_string = lpszRegistryValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
if (hkSetupHive) RegCloseKey(hkSetupHive);
|
||||
return lReturnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Desc: Create the infrastructure for thread safe acccess to the infrastructure
|
||||
// layer of the screen saver.
|
||||
//
|
||||
|
|
|
@ -126,6 +126,7 @@ protected:
|
|||
int UtilGetRegKey(LPCTSTR name, DWORD &keyval);
|
||||
int UtilSetRegKey(LPCTSTR name, DWORD value);
|
||||
int UtilGetRegStartupStr(LPCTSTR name, LPTSTR str);
|
||||
int UtilGetRegDirectoryStr(LPCTSTR name, char **dir_string);
|
||||
|
||||
BOOL CreateInfrastructureMutexes();
|
||||
|
||||
|
|
Loading…
Reference in New Issue