1. 检查是否安装jdk
function OnBegin()
begin
Disable (BACKBUTTON);
if(!MAINTENANCE)then
SdLicense2 ("License ", "", "", SUPPORTDIR ^ "sn.txt", FALSE);
endif ; // 获取注册表信息
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); // 检查是否安装jdk
if (RegDBKeyExist ("SOFTWARE\\JavaSoft\\Java Development Kit\\1.7.0_17") < ) then
if(LaunchAppAndWait (SUPPORTDIR^"jdk-8u131-windows-i586.exe","", LAAW_OPTION_WAIT)<)then
MessageBox ("您的系统没有安装 JDK 1.6.0_04 t! ", INFORMATION);
endif;
endif;
end;
2. 安装结束前设置环境变量
//安装结束之前,设置java_home环境变量 function OnEnd()
STRING szFeatureName;
STRING serviceTarget;
STRING szDocFile;
STRING szKey;
NUMBER nvType;
STRING svValue;
NUMBER nvSize;
begin //检查是否已经安装jdk szKey = "SOFTWARE\\JavaSoft\\Java Development Kit\\1.7.0_17";
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); //如果已经安装则设置环境变量 java_home
if (RegDBKeyExist(szKey)=) then//如果该注册表值存在
if(RegDBGetKeyValueEx(szKey,"JavaHome",nvType,svValue,nvSize)=) then
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
if(RegDBSetKeyValueEx(szKey, "JAVA_HOME", REGDB_STRING, svValue, -)<) then
MessageBox ("Javahome create failed, please set it manually!", SEVERE);
endif;
endif;
endif;