实现原理:判断是否存在,是通过查找注册表是否含有相应标识来判断的。
注意:XP与WIN7系统注册表保存方式不一样,32位与64位操作系统注册表保存方式也不一样,需要分别判断。在此只判断32位操作系统的情况。
源码:
检查是否有安装Oracle
function NUMBER CheckOracleISExist() STRING svOraclePath,nvValue;NUMBER nKeyType,nvType, nvSize;begin// defaut regedit rootRegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); //oralce regedit path if(RegDBGetKeyValueEx("SOFTWARE\\ORACLE\\ALL_HOMES","DEFAULT_HOME",nvType,nvValue,nvSize) = 0) thenreturn 0;endif;return -1;end;// SQL Server 2000, SQL Server 2005, SQL Server 2008,
// SQL Server 2005 Express,SQL Server 2008 Express //检查是否有安装SQL Server function NUMBER CheckSQLServer() STRING nvValue;NUMBER nvType, nvSize;begin//return -1;// defaut regedit rootRegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); // SQL Server 2000 if(RegDBGetKeyValueEx("SOFTWARE\\Microsoft\\Microsoft SQL Server","InstalledInstances",nvType,nvValue,nvSize) = 0) thenreturn 0;endif;//SQL Server 2005 Versionif(RegDBGetKeyValueEx("SOFTWARE\\Microsoft\\Microsoft SQL Server 2005 Redist\\BOL\\2052\\CurrentVersion","Version",nvType,nvValue,nvSize) = 0) thenreturn 0;endif; //SQL Server 2008 Express //if(RegDBGetKeyValueEx("SOFTWARE\\Microsoft\\Microsoft SQL Server 2008 Redist\\SQLNCLI10\\2052\\CurrentVersion","Version",nvType,nvValue,nvSize) = 0) then// return 0;//endif; // Expressif(RegDBGetKeyValueEx("SOFTWARE\\Microsoft\\Microsoft SQL Server\SQLEXPRESS\setup","SQLPath",nvType,nvValue,nvSize) = 0) thenreturn 0;endif;return -1;end;