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