//
//    GetRegValue
//    ===========
//
//    Recover a value from the system registry
//
CString CLocaleScanner::GetRegValue (LPCSTR pszRegKey, LPCSTR pszRegItem)
{
	CString strResult;

	// work out which "hive" to access
	CString strRegKey(pszRegKey);
	CString strHive = BreakString(strRegKey, '\\');
	HKEY hkHive = NULL, hkSubKey;
	if (strHive == "HKEY_CLASSES_ROOT")
		hkHive = HKEY_CLASSES_ROOT;
	if (strHive == "HKEY_CURRENT_CONFIG")
		hkHive = HKEY_CURRENT_CONFIG;
	if (strHive == "HKEY_CURRENT_USER")
		hkHive = HKEY_CURRENT_USER;
	if (strHive == "HKEY_LOCAL_MACHINE")
		hkHive = HKEY_LOCAL_MACHINE;
	if (strHive == "HKEY_USERS")
		hkHive = HKEY_USERS;

	if (hkHive)
	{
		int nStatus = RegOpenKeyEx(hkHive, strRegKey, 0, KEY_QUERY_VALUE, &hkSubKey);
		if (nStatus == ERROR_SUCCESS)
		{
			// key opened ok - look for matching item
			DWORD dwIndex = 0;
			unsigned char szThisRegValue[1024];
			DWORD dwType;
			DWORD dwRegValueLen = sizeof(szThisRegValue);

			int nStatus = RegQueryValueEx(hkSubKey ,pszRegItem ,NULL ,&dwType ,szThisRegValue ,&dwRegValueLen);
			if (nStatus == ERROR_SUCCESS)
			{
				// FOUND IT - sort out the type conversion
				switch (dwType)
				{
					case REG_BINARY:
						{
							// write as a sequence of hex values
							for (DWORD dw = 0 ; dw < dwRegValueLen ; dw++)
							{
								BYTE b = szThisRegValue[dw];
								CString strThisBit;
								strThisBit.Format("%2.2X ", b);
								strResult += strThisBit;
							}
							strResult.TrimRight();
						}
						break;

					case REG_DWORD:
//					case REG_DWORD_LITTLE_ENDIAN:
						strResult.Format("%d", *((LPDWORD)szThisRegValue));
						break;
						
					case REG_SZ:
						strResult = szThisRegValue;
						break;

					case REG_EXPAND_SZ:
						{
							char szBuffer[1024];
							ExpandEnvironmentStrings ((LPCSTR)szThisRegValue, szBuffer, sizeof(szBuffer));
							strResult = szBuffer;
						}
						break;

					case REG_MULTI_SZ:
						{
							for (char * p = (LPSTR)szThisRegValue ; *p != NULL ; p += strlen(p) + 1)
							{
								if (strResult.GetLength())
									strResult += ';';
								strResult += p;
							}
						}
						break;

					case REG_DWORD_BIG_ENDIAN:
					case REG_LINK:
					case REG_NONE:
//					case REG_QWORD:
//					case REG_QWORD_LITTLE_ENDIAN:
					case REG_RESOURCE_LIST:
					default:
						strResult.Format("Unsupported Registry Data Type %d", dwType);
						break;
				}
			}
		}
		RegCloseKey(hkSubKey);
	
	
	}
	return strResult;
}
Beispiel #2
0
BOOL UpdateEDBSRegistry(BOOL fRegister)
{
	CRegKey regTRiAS;
	CRegKey regEDBS;
	char  straConfig[MAX_PATH];
	DWORD cbConfig;
	CString strConfigPath;
	CString strRegKey(TRiAS_REGKEY);

	if( fRegister ) {
		regEDBS.Create(HKEY_CURRENT_USER, strRegKey + "Extensions\\TRiAS.EDBSALK.1\\ImportFormat");
		regEDBS.SetValue("{73645434-AED5-11D3-8E7B-00105AF354F9}","ConfigPage");
		regEDBS.Close();

		regEDBS.Create(HKEY_CURRENT_USER, strRegKey + "Extensions\\TRiAS.EDBSALK.1\\Config");
		cbConfig = MAX_PATH;
		if( ERROR_SUCCESS != regEDBS.QueryValue(straConfig, "ConfigPath", &cbConfig ) ) {
			regTRiAS.Open(HKEY_CURRENT_USER, strRegKey + "Directories");
			cbConfig = MAX_PATH;
			if( ERROR_SUCCESS == regTRiAS.QueryValue(straConfig, "Config", &cbConfig ) ) {
				strConfigPath = straConfig;
				strConfigPath += "\\EDBS\\";
				regTRiAS.Close();
			}
			else {
				regTRiAS.Close();
#if _TRiAS_VER < 0x300
				regTRiAS.Open(HKEY_CLASSES_ROOT,".ris\\ShellNew", KEY_READ);
#else
				regTRiAS.Open(HKEY_CLASSES_ROOT,".riw\\ShellNew", KEY_READ);
#endif
				cbConfig = MAX_PATH;
				if (ERROR_SUCCESS == regTRiAS.QueryValue(straConfig, "command", &cbConfig)) {
					strConfigPath = straConfig;
                    for (int i = 0; i < 1; ++i) {
					    while (strConfigPath.GetLength() > 0 && strConfigPath.Right(1) != "\\")
						    strConfigPath = strConfigPath.Left(strConfigPath.GetLength() - 1);
                    }
					strConfigPath = strConfigPath + "EDBS\\";
				}
				regTRiAS.Close();
			}
			regEDBS.SetValue(strConfigPath, "ConfigPath");
		}
		cbConfig = MAX_PATH;
		if( ERROR_SUCCESS != regEDBS.QueryValue(straConfig,"ConfigFile", &cbConfig ) ) {
			regEDBS.SetValue("Default","ConfigFile");
		}
		if( ERROR_SUCCESS != regEDBS.QueryValue(cbConfig,"ConfigBase") ) {
			regEDBS.SetValue(0xFFFFFFFD,"ConfigBase");
		}
		regEDBS.Close();

	}
	else {
		if( ERROR_SUCCESS == regEDBS.Open(HKEY_CURRENT_USER,strRegKey + "Extensions\\TRiAS.EDBSALK.1\\ImportFormat") ) {
			regEDBS.DeleteValue("ConfigPage");
			regEDBS.Close();
		}
	
//		if( ERROR_SUCCESS == regEDBS.Open(HKEY_CURRENT_USER,strRegKey + "Extensions") ) {
//			regEDBS.DeleteSubKey("TRiAS.EDBS");
//			regEDBS.Close();
//		}
	}

	return true;	// alles ok
}
Beispiel #3
0
void CCfg::Save()
{
 CRegKey regEDBS;
 DWORD dwConfigBase;
 CString strRegKey(TRiAS_REGKEY);

	regEDBS.Open(HKEY_CURRENT_USER,strRegKey + "Extensions\\TRiAS.EDBSALK.1\\Config");

	regEDBS.SetValue( m_strConfigPath,"ConfigPath");
	regEDBS.SetValue( m_strConfigFile, "ConfigFile");

	regEDBS.QueryValue( dwConfigBase,"ConfigBase" );

	if( m_tDefaultObjectMapping )
		dwConfigBase |= EDBSCFG_DEFAULTOBJECTMAPPING;
	else
		dwConfigBase &= ~EDBSCFG_DEFAULTOBJECTMAPPING;
	if( m_tOverwriteRules )
		dwConfigBase |= EDBSCFG_OVERWRITERULES;
	else
		dwConfigBase &= ~EDBSCFG_OVERWRITERULES;
	if( m_tImportAreas )
		dwConfigBase |= EDBSCFG_IMPORTAREAS;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTAREAS;
	if( m_tImportLines )
		dwConfigBase |= EDBSCFG_IMPORTLINES;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTLINES;
	if( m_tImportPoints )
		dwConfigBase |= EDBSCFG_IMPORTPOINTS;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTPOINTS;
	if( m_tImportText )
		dwConfigBase |= EDBSCFG_IMPORTTEXT;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTTEXT;

	if( m_tCreateBIgeom )
		dwConfigBase |= EDBSCFG_CREATEBIGEOM;
	else
		dwConfigBase &= ~EDBSCFG_CREATEBIGEOM;
	if( m_tCreateBItext )
		dwConfigBase |= EDBSCFG_CREATEBITEXT;
	else
		dwConfigBase &= ~EDBSCFG_CREATEBITEXT;

	if( m_tImportKSIG )
		dwConfigBase |= EDBSCFG_IMPORTKSIG;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTKSIG;
	if( m_tImportVPKT )
		dwConfigBase |= EDBSCFG_IMPORTVPKT;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTVPKT;
	

	if( m_tImportAttr )
		dwConfigBase |= EDBSCFG_IMPORTATTR;
	else
		dwConfigBase &= ~EDBSCFG_IMPORTATTR;
	if( m_tCreateEDBSattr )
		dwConfigBase |= EDBSCFG_CREATEEDBSATTR;
	else
		dwConfigBase &= ~EDBSCFG_CREATEEDBSATTR;
	if( m_tCreateBIattr )
		dwConfigBase |= EDBSCFG_CREATEBIATTR;
	else
		dwConfigBase &= ~EDBSCFG_CREATEBIATTR;

	if( m_tCreateAttributeDateiname )
		dwConfigBase |= EDBSCFG_CREATEATTRDATEINAME;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTRDATEINAME;
	if( m_tCreateAttributeFolie )
		dwConfigBase |= EDBSCFG_CREATEATTRFOLIE;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTRFOLIE;
	if( m_tCreateAttributeObjektart )
		dwConfigBase |= EDBSCFG_CREATEATTROBJEKTART;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTROBJEKTART;
	if( m_tCreateAttributeObjektnummer )
		dwConfigBase |= EDBSCFG_CREATEATTROBJEKTNUMMER;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTROBJEKTNUMMER;
	if( m_tCreateAttributeObjektteilnummer )
		dwConfigBase |= EDBSCFG_CREATEATTROBJEKTTEILNUMMER;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTROBJEKTTEILNUMMER;
	if( m_tCreateAttributeObjektteilnummerK )
		dwConfigBase |= EDBSCFG_CREATEATTROBJEKTTEILNUMMERK;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTROBJEKTTEILNUMMERK;
	if( m_tCreateAttributeAktualitaet )
		dwConfigBase |= EDBSCFG_CREATEATTRAKTUALITAET;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTRAKTUALITAET;
	if( m_tCreateAttributeRegeln )
		dwConfigBase |= EDBSCFG_CREATEATTRREGELN;
	else
		dwConfigBase &= ~EDBSCFG_CREATEATTRREGELN;

	regEDBS.SetValue( dwConfigBase, "ConfigBase");

	regEDBS.Close();


}
Beispiel #4
0
void CCfg::Load()
{
	CRegKey regEDBS;
	char  straConfig[MAX_PATH];
	DWORD cbConfig;
	CString strConfigPath;
	CString strBuffer;
	WIN32_FIND_DATA FileData;   // Data structure describes the file found
	HANDLE hSearch;             // Search handle returned by FindFirstFile
	CString strRegKey(TRiAS_REGKEY);

	regEDBS.Open(HKEY_CURRENT_USER,strRegKey + "Config");
	regEDBS.QueryValue( m_dwSystemAdministration,"SystemAdministration" );
	cbConfig = MAX_PATH;
	if( ERROR_SUCCESS == regEDBS.QueryValue(straConfig, "TRiASName", &cbConfig ) )
		m_strTRiASName = straConfig;
	else
		m_strTRiASName = "TRiAS®";
	regEDBS.Close();

	regEDBS.Open(HKEY_CURRENT_USER,strRegKey + "Extensions\\TRiAS.EDBSALK.1\\Config");

	if( ERROR_SUCCESS != regEDBS.QueryValue( m_dwReportBase, "ReportBase" ) )
		m_dwReportBase = 0;

	if( ERROR_SUCCESS != regEDBS.QueryValue( m_dwConfigBase, "ConfigBase" ) )
		m_dwConfigBase = 0xFFFFFFFD;

	m_tDefaultObjectMapping = (0 != (m_dwConfigBase & EDBSCFG_DEFAULTOBJECTMAPPING));
	m_tOverwriteRules = (0 != (m_dwConfigBase & EDBSCFG_OVERWRITERULES));

	m_tImportAreas = (0 != (m_dwConfigBase & EDBSCFG_IMPORTAREAS));
	m_tImportLines = (0 != (m_dwConfigBase & EDBSCFG_IMPORTLINES));
	m_tImportPoints = (0 != (m_dwConfigBase & EDBSCFG_IMPORTPOINTS));
	m_tImportText = (0 != (m_dwConfigBase & EDBSCFG_IMPORTTEXT));
	
	m_tCreateBIgeom = (0 != (m_dwConfigBase & EDBSCFG_CREATEBIGEOM));
	m_tCreateBItext = (0 != (m_dwConfigBase & EDBSCFG_CREATEBITEXT));

	m_tImportAttr = (0 != (m_dwConfigBase & EDBSCFG_IMPORTATTR));
	m_tCreateEDBSattr = (0 != (m_dwConfigBase & EDBSCFG_CREATEEDBSATTR));
	m_tCreateBIattr = (0 != (m_dwConfigBase & EDBSCFG_CREATEBIATTR));
	
	m_tImportKSIG = (0 != (m_dwConfigBase & EDBSCFG_IMPORTKSIG));
	m_tImportVPKT = (0 != (m_dwConfigBase & EDBSCFG_IMPORTVPKT));

	m_tCreateAttributeDateiname = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTRDATEINAME));
	m_tCreateAttributeFolie = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTRFOLIE));
	m_tCreateAttributeObjektart = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTROBJEKTART));
	m_tCreateAttributeObjektnummer = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTROBJEKTNUMMER));
	m_tCreateAttributeObjektteilnummer = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTROBJEKTTEILNUMMER));
	m_tCreateAttributeObjektteilnummerK = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTROBJEKTTEILNUMMERK));
	m_tCreateAttributeAktualitaet = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTRAKTUALITAET));
	m_tCreateAttributeRegeln = (0 != (m_dwConfigBase & EDBSCFG_CREATEATTRREGELN));

	cbConfig = MAX_PATH;
	if( ERROR_SUCCESS == regEDBS.QueryValue(straConfig,"ConfigFile", &cbConfig ) ) {
		m_strConfigFile = straConfig;
		if( m_strConfigFile == "Default" ) 
			m_tDefaultObjectMapping = true;
		cbConfig = MAX_PATH;
		if( ERROR_SUCCESS == regEDBS.QueryValue(straConfig,"ConfigPath", &cbConfig ) )
			m_strConfigPath = straConfig;
	}

	cbConfig = MAX_PATH;
	if( ERROR_SUCCESS == regEDBS.QueryValue(straConfig,"ObjectClassesTRiAS", &cbConfig ) )
		m_strObjectClassesTRiAS = straConfig;
	else
		m_strObjectClassesTRiAS = "D";

	cbConfig = MAX_PATH;
	if( ERROR_SUCCESS == regEDBS.QueryValue(straConfig,"ObjectAttributesTRiAS", &cbConfig ) )
		m_strObjectAttributesTRiAS = straConfig;
	else
		m_strObjectAttributesTRiAS = "49";

	regEDBS.Close();

// ermitteln, ob Datenbanken im EDBS-Konfigurationsverteichnis vorhanden sind.

	hSearch = FindFirstFile (TEXT(m_strConfigPath + "*.mdb"), &FileData);
//	if( (hSearch != INVALID_HANDLE_VALUE) || (DEX_QueryMode() & QMSysAdmin) )
	if( (hSearch != INVALID_HANDLE_VALUE) || (m_dwSystemAdministration & QMSysAdmin) )
		m_tEnabled = true;
	FindClose (hSearch);
}