zoukankan      html  css  js  c++  java
  • InstallShield安装jdk并设置环境变量

    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") < 0) then
    if(LaunchAppAndWait (SUPPORTDIR^"jdk-8u131-windows-i586.exe","", LAAW_OPTION_WAIT)<0)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)=1) then//如果该注册表值存在
    if(RegDBGetKeyValueEx(szKey,"JavaHome",nvType,svValue,nvSize)=0) then
    szKey = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment";
    if(RegDBSetKeyValueEx(szKey, "JAVA_HOME", REGDB_STRING, svValue, -1)<0) then
    MessageBox ("Javahome create failed, please set it manually!", SEVERE);
    endif;
    endif;
    endif;
  • 相关阅读:
    面试代码基础(一)从strstr说起
    面试笔试总结(二)之 C++基础
    面试笔试总结(一)之 C++基础
    HMM代码实践
    计算两篇文章相似度代码
    主题模型
    mysql5.6.34-debug Source distribution在树莓派下编译的几个错误
    windows守护进程脚本
    fastcgi模式下设置php最大执行时间
    mysql基础知识笔记
  • 原文地址:https://www.cnblogs.com/bincoding/p/8604591.html
Copyright © 2011-2022 走看看