sorry I'm english is bad,modify COSidHelper::COSidHelper() like this:
COSidHelper::COSidHelper()
{
CString strPath;
CString strFileName;
CString strLine;
CString strBlock;
int nIndex;
int nCountOpen = 0;
int nCountClose = 0;
CStdioFile f;
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraClient10g_home1"), _T("ORACLE_HOME"), strPath );
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraDb10g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_OraClient10g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_OraDb10g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraClient11g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraDb11g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_OraClient11g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_OraDb11g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraClient12g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraDb12g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_OraClient12g_home1"), _T("ORACLE_HOME"), strPath );
}
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_OraDb12g_home1"), _T("ORACLE_HOME"), strPath );
}
strFileName.Format( _T("%s\\network\\admin\\tnsnames.ora"), strPath );
if( (_taccess( strFileName, 0 )) == -1 )
{
strFileName.Format( _T("%s\\net80\\admin\\tnsnames.ora"), strPath );
if( (_taccess( strFileName, 0 )) == -1 )
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\ALL_HOMES\\ID0"), _T("PATH"), strPath );
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Wow6432Node\\ORACLE\\ALL_HOMES\\ID0"), _T("PATH"), strPath );
}
strFileName.Format( _T("%s\\network\\admin\\tnsnames.ora"), strPath );
if( (_taccess( strFileName, 0 )) == -1 )
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\ALL_HOMES\\ID0"), _T("PATH"), strPath );
if (strPath.IsEmpty())
{
GetRegKeyValue( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Wow6432Node\\ORACLE\\ALL_HOMES\\ID0"), _T("PATH"), strPath );
}
strFileName.Format( _T("%s\\net80\\admin\\tnsnames.ora"), strPath );
}
}
}
if( f.Open( strFileName, CFile::typeText ) )
{
while( f.ReadString( strLine ) )
{
strLine.TrimLeft();
strLine.TrimRight();
if ( strLine.Left( 1 ) == _T("#") || strLine.IsEmpty() )
{
continue;
}
strBlock += strLine;
for( nIndex = 0; nIndex < strLine.GetLength(); nIndex ++ )
{
switch( strLine[nIndex] )
{
case '(':
nCountOpen++;
break;
case ')':
nCountClose++;
break;
}
}
if ( nCountOpen == nCountClose && nCountOpen > 0 )
{
strLine = strBlock.Left( strBlock.Find( _T("=") ) );
strLine.TrimRight();
m_strArray.Add( strLine );
strBlock.Empty();
nCountOpen = 0;
nCountClose = 0;
}
}
f.Close();
}
}
|