/** * @brief Fills the given informations structure using windows registry HKEY_LOCAL_MACHINE/subkey */ void _ddc_get_informations_from_registry( ddc_display_device_info_t * informations, std::string subKey ) { // driverVersionStr = 8.17.11.9745 for NVidia and / 8.762.0.0 for AMD const std::string driverVersionStr = get_string_from_registry( subKey, "DriverVersion" ); std::vector<std::string> driverVersion = split_string(driverVersionStr, '.'); strncpy( informations->driverVersion, driverVersionStr.c_str(), sizeof(informations->driverVersion) ); copy( informations->driverVersionNumber, driverVersion, 4 ); // 4-3-2010 for NVidia and 8-3-2010 for AMD const std::string driverDateStr = get_string_from_registry( subKey, "DriverDate" ); std::vector<std::string> driverDate = split_string(driverDateStr, '-'); strncpy( informations->driverDate, driverDateStr.c_str(), sizeof(informations->driverDate) ); copy( informations->driverDateNumber, driverDate, 3 ); // empty for NVidia and 10.8 for AMD const std::string catalystVersionStr = get_string_from_registry( subKey, "Catalyst_Version" ); std::vector<std::string> catalystVersion = split_string(catalystVersionStr, '.'); strncpy( informations->catalystVersion, catalystVersionStr.c_str(), sizeof(informations->catalystVersion) ); copy( informations->catalystVersionNumber, catalystVersion, 2 ); // OpenGLDriverName // nvoglv64 for NVidia and atig6pxx.dll for AMD const std::string openglDriverNameStr = get_string_from_registry( subKey, "OpenGLDriverName" ); strncpy( informations->openglDriverName, openglDriverNameStr.c_str(), sizeof(informations->openglDriverName) ); }
static char * get_java_home_from_registry(char *java_key) { char *version = get_string_from_registry(HKEY_LOCAL_MACHINE, java_key, "CurrentVersion"); if (version) { char *sep = "\\"; char *full_java_key = malloc(strlen(java_key)+strlen(sep)+strlen(version)+1); strcpy(full_java_key, java_key); strcat(full_java_key, sep); strcat(full_java_key, version); return get_string_from_registry(HKEY_LOCAL_MACHINE, full_java_key, "JavaHome"); } return NULL; }
// returns a windows-friendly version of the binary dir (no "/cygdrive/...") // for compatibility with CreateProcess() const char * get_asf_bin_dir_win() { #if defined(win32) if (!s_bin_dir_win) { /* on windows, pull the install dir from the registry */ char str_value[REG_VALUE_SIZE]; get_string_from_registry(s_asf_install_dir_key, str_value); s_bin_dir_win = STRDUP(str_value); /* remove trailing path separator, if one is present */ if (s_bin_dir_win[strlen(s_bin_dir_win) - 1] == DIR_SEPARATOR) s_bin_dir_win[strlen(s_bin_dir_win) - 1] = '\0'; } return s_bin_dir_win; #else /* normal version will work just fine on non-Win */ return get_asf_bin_dir(); #endif }
const char * get_asf_share_dir() { //print_all_reg_vals(); if (!s_share_dir) { #if defined(win32) /* on windows, pull the share dir from the registry */ char str_value[REG_VALUE_SIZE]; get_string_from_registry(s_asf_share_dir_key, str_value); s_share_dir = strdup(str_value); #else /* on UNIX, assume ASF_SHARE_DIR has been set by the configure */ /* script -- in config.h */ s_share_dir = strdup(ASF_SHARE_DIR); /* See if this works - check for a known file which */ /* is in the asf share directory. */ if (!check_for_known_file_in_share_dir(s_share_dir)) { const char path_sep = ':'; const char *share_p; char *path, *buf, *share, *p; int found = 0; //printf("Known file not in config.h's share dir: %s\n", s_share_dir); //printf("Searching the path...\n"); /* kludgery! Must find the location of the share dir the hard */ /* way, which is to search the directories in the user's path, */ /* go '../share/asf_tools' relative to that, and check for the */ /* known file. */ /* first: it might not be share/asf_tools, get what it really is */ share_p = strstr(ASF_SHARE_DIR, "share"); if (!share_p) { /* this is bad... */ printf("Bad configure? 'share' not found in default share dir.\n"); printf("Using default share dir: %s\n", s_share_dir); return s_share_dir; } --share_p; /* Add on the tool name, e.g. share/asf_tools/mapready */ share = MALLOC(sizeof(char)*(strlen(share_p) + strlen(TOOL_SUITE_SHARE_DIR) + 10)); sprintf(share, "%s/%s", share_p, TOOL_SUITE_SHARE_DIR); /* now build the full buffer */ path = getenv("PATH"); buf = MALLOC(sizeof(char)*(strlen(path) + strlen(share) + 10)); p = path; do { char * q = strchr(p + 1, path_sep); if (!q) q = path + strlen(path); /* last item in path */ int i; for (i = 0; i < q - p; ++i) buf[i] = p[i]; buf[i] = '\0'; // If path item ends with a separator, pop that off if (buf[strlen(buf) - 1] == '/') buf[strlen(buf) - 1] = '\0'; //printf("Checking %s ...\n", buf); /* only try this one if it ends with 'bin' */ if (strcmp(buf + strlen(buf) - 3, "bin") == 0) { *(buf + strlen(buf) - 4) = '\0'; strcat(buf, share); if (check_for_known_file_in_share_dir(buf)) { free(s_share_dir); s_share_dir = strdup(buf); found = 1; //printf(" Found in %s!\n", buf); break; } //printf(" Not found in %s.\n", buf); } p = q; } while (*p++ != '\0'); if (!found) printf("Using default share dir: %s\n", s_share_dir); FREE(buf); FREE(share); } #endif /* remove trailing path separator, if one is present */ if (s_share_dir[strlen(s_share_dir) - 1] == DIR_SEPARATOR) { s_share_dir[strlen(s_share_dir) - 1] = '\0'; } //printf("Share dir: %s\n", s_share_dir); } return s_share_dir; }
const char * get_asf_bin_dir() { if (!s_bin_dir) { #if defined(win32) /* on windows, pull the install dir from the registry */ char str_value[REG_VALUE_SIZE]; char str_value_fixed[REG_VALUE_SIZE]; int i,j; get_string_from_registry(s_asf_install_dir_key, str_value); for (i = j = 0; i <= strlen(str_value); ++i, ++j) { if (i == 0) { char drive = str_value[0]; char colon = str_value[1]; char backslash = str_value[2]; if (colon == ':' && backslash == '\\') { sprintf(str_value_fixed, "/cygdrive/%c/", tolower(drive)); i += 3; j += strlen(str_value_fixed); } } switch (str_value[i]) { //case ' ': // str_value_fixed[j] = '\\'; // str_value_fixed[j+1] = ' '; // ++j; // break; //case '\\': // str_value_fixed[j] = '/'; // break; default: str_value_fixed[j] = str_value[i]; break; } } s_bin_dir = strdup(str_value_fixed); //printf("bin_dir : %s\n", s_bin_dir); #else /* on UNIX, assume ASF_INSTALL_DIR has been set by the configure */ /* script -- in config.h */ s_bin_dir = strdup(ASF_BIN_DIR); /* See if this works - check for a known file which */ /* is in the asf binaries directory. */ if (!check_for_known_file_in_bin_dir(s_bin_dir)) { const char path_sep = ':'; char *path, *buf, *p; int found = 0; //printf("Known file not in config.h's bin dir: %s\n", s_bin_dir); //printf("Searching the path...\n"); path = getenv("PATH"); buf = MALLOC(strlen(path)); p = path; do { char * q = strchr(p + 1, path_sep); if (!q) q = path + strlen(path); /* last item in path */ int i; for (i = 0; i < q - p; ++i) buf[i] = p[i]; buf[i] = '\0'; //printf("Checking %s ...\n", buf); if (check_for_known_file_in_bin_dir(buf)) { free(s_bin_dir); s_bin_dir = strdup(buf); found = 1; //printf(" Found in %s!\n", buf); break; } //printf(" Not found in %s.\n", buf); p = q; } while (*p++ != '\0'); if (!found) printf("Using default bin dir: %s\n", s_bin_dir); FREE(buf); } #endif /* remove trailing path separator, if one is present */ if (s_bin_dir[strlen(s_bin_dir) - 1] == DIR_SEPARATOR) { s_bin_dir[strlen(s_bin_dir) - 1] = '\0'; } } return s_bin_dir; }