Example #1
0
// Reads a value from the Cygwin registry key, trying both HKLM and HKCU.
wxString read_cygwin_registry_key(const wxString &key_path, const wxString &key, const wxString &default_value = wxEmptyString) {
	wxString value;

	// Check in "local machine", the "install for everyone" location.
	{
		wxRegKey cygKey(wxT("HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygnus Solutions\\Cygwin\\") + key_path);
		if( cygKey.Exists() && cygKey.HasValue(key)) {
			cygKey.QueryValue(key, value);
		}
	}

	if (!value.empty())
		return value;

	// Also check "current user" (might be needed if user did not have admin rights during install)
	{
		wxRegKey cygKey(wxT("HKEY_CURRENT_USER\\SOFTWARE\\Cygnus Solutions\\Cygwin\\") + key_path);
		if( cygKey.Exists()  && cygKey.HasValue(key)) {
			cygKey.QueryValue(key, value);
		}
	}

	if (!value.empty())
		return value;
	
	return default_value;
}
Example #2
0
// Reads a value from the Cygwin registry key, trying both HKLM and HKCU.
// In Cygwin 1.7 only the install location is in registry
wxString read_cygwin17_registry_key(const wxString &default_value = wxEmptyString) {
	const wxString key = wxT("rootdir");
	wxString value;

	// Check "current user" ('just me').
	{
		wxRegKey cygKey(wxT("HKEY_CURRENT_USER\\SOFTWARE\\Cygwin\\setup"));
		if( cygKey.Exists()  && cygKey.HasValue(key)) {
			cygKey.QueryValue(key, value);
		}
	}

	if (!value.empty())
		return value;
	
	// Also check in "local machine", the "install for everyone" location.
	{
		wxRegKey cygKey(wxT("HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygwin\\setup"));
		if( cygKey.Exists() && cygKey.HasValue(key)) {
			cygKey.QueryValue(key, value);
		}
	}

	if (!value.empty())
		return value;

	return default_value;
}
Example #3
0
wxString GetCygwinDir() { // static
	wxString cygPath;

	// Check if we have a cygwin installation
	wxRegKey cygKey(wxT("HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
	if( cygKey.Exists() ) {
		if (cygKey.HasValue(wxT("native"))) {
			cygKey.QueryValue(wxT("native"), cygPath);
		}
	}

	// Also check "current user" (might be needed if user did not have admin rights during install)
	if (cygPath.empty()) {
		wxRegKey cygKey2(wxT("HKEY_CURRENT_USER\\SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
		if( cygKey2.Exists() ) {
			if (cygKey2.HasValue(wxT("native"))) {
				cygKey2.QueryValue(wxT("native"), cygPath);
			}
		}
	}

	return cygPath;
}