杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2544|回复: 0

判断是否安装某软件,没有安装则从软件安装

[复制链接]
发表于 2017-3-1 18:44:09 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. //===========================================================================
  2. //
  3. //  File Name:    Setup.rul
  4. //
  5. //  Description:  Blank setup main script file
  6. //
  7. //  Comments:     Blank setup is an empty setup project. If you want to
  8. //                  create a new project via. step-by step instructions use the
  9. //                  Project Assistant.
  10. //
  11. //===========================================================================

  12. // Included header files ----------------------------------------------------
  13. #include "ifx.h"   

  14. function OnBegin()   
  15. STRING strFramework;   
  16. STRING strVersion;     
  17. INT iVersion;
  18. begin      
  19.     SetTitle(IFX_PRODUCT_NAME + " 安装向导", 0, BACKGROUNDCAPTION);   
  20.    
  21.     SdShowMsg("安装程序正在检测系统必备组件。。。",TRUE);  
  22.     Delay(2);
  23.     SdShowMsg("",FALSE);  
  24.                      
  25.     RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );  
  26.     strFramework = SRCDIR ^ "dotnetfx35"^"wcu"^"dotNetFramework"^"dotNetFx35setup.exe";//放在Disk1上的可执行文件路径
  27.     if(RegDBKeyExist("SOFTWARE\\Microsoft\\.NETFramework\\v3.0") < 0)
  28.     then   
  29.    
  30.         VerGetFileVersion(WINDIR^"system32"^"msiexec.exe",strVersion); //取得文件版本号(判断windows installer版本)
  31.         if(strVersion < "3.1")
  32.         then   
  33.             if(LaunchAppAndWait(SUPPORTDIR^"WindowsInstaller-KB893803-v2-x86.exe","",LAAW_OPTION_WAIT)<0)
  34.             then      
  35.                 MessageBox("WindowsInstaller error",INFORMATION);   
  36.                 abort;
  37.             endif;
  38.         endif;   

  39.                
  40.         if( LaunchAppAndWait(strFramework, "/q:a/l" ,LAAW_OPTION_WAIT) < 0)
  41.         then
  42.             SprintfBox(MB_OK,".NET安装",".NET FrameWork安装失败!");   
  43.             abort;
  44.         endif;
  45.     endif;            
  46.             
  47.     if(RegDBKeyExist("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{1F1C2DFC-2D24-3E06-BCB8-725134ADF989}") < 0)//判断机器是否安装了c++2008运行库
  48.     then   
  49.         if(LaunchAppAndWait(SUPPORTDIR^"(C++2008)vcredist2008.exe","/s",WAIT)<0)
  50.         then      
  51.             MessageBox("(C++2008)vcredist2008 error",INFORMATION);     
  52.             abort;
  53.         endif;
  54.     endif;
  55.    
  56.     if(RegDBKeyExist("SOFTWARE\\MapInfo\\MapInfo") < 0)   
  57.     then   
  58.         if(LaunchAppAndWait(SUPPORTDIR^"MapX4.5.exe","",WAIT)<0)
  59.         then      
  60.             MessageBox("MapX4.5 error",INFORMATION);   
  61.             abort;
  62.         endif;
  63.     endif;
  64. end;
复制代码
又一个实例
  1. function OnBegin()
  2. string svCurrentDir;
  3. begin
  4. // TO DO: you may change default non-UI setting, for example
  5. //
  6. // You may also perform your custom initialization steps, check requirements, etc.


  7. //GetCurrentDir(svCurrentDir);
  8. //svCurrentDir =  svCurrentDir+"\\dotNetFx40_Full_x86_x64.exe";

  9. svCurrentDir =  SUPPORTDIR^"\\dotNetFx40_Full_x86_x64.exe";
  10. RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);  //设置默认的注册表键值根节点
  11. // 判断是否存在.net
  12. if (RegDBKeyExist ("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4.0") <0 &&RegDBKeyExist ("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4") < 0) then
  13. //当上面判断了没有安装.net这个软件时,则启动光盘里
  14. //dotnetfx.exe安装程序来安装。
  15.      MessageBox ("检测到本机未安装.Net FrameWork 4.0,下一步将会先安装.Net FrameWork 4.0 ", INFORMATION);  
  16.      if(LaunchAppAndWait (svCurrentDir ,"", LAAW_OPTION_WAIT)<0) then     
  17.      MessageBox ("找不到安装程序或者安装出错,请双击运行dotNetFx40_Full_x86_x64.exe,手动安装", INFORMATION);
  18.      return 0;
  19.      endif;        
  20. endif;


  21. end;
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-4-29 10:27 , Processed in 0.114804 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表