用Installshield制作软件包常用的InstallScript---4

7.判断操作系统
if !(SYSINFO.WINNT.bWinServer2003 || SYSINFO.WINNT.bWinXP) then
       if SELECTED_LANGUAGE = ISLANG_ENGLISH then
          szMsg = "Your current operation system cannot satisfy the requests.\n The operation system should be Windows2003 or WindowsXP. ";
       else
        szMsg = "您当前的操作系统不能满足要求,操作系统必须是Windows2003或者WindowsXP。";
       endif;
         MessageBox (szMsg,INFORMATION);
       abort; 
 endif;

8.判断当前用户是否为admin
szMsg = "您没有足够的权限在本计算机中安装该软件,请与系统管理员联系\n或者注销当前用户用管理员账户重新登陆系统。";
if (!SYSINFO.WINNT.bAdmin_Logged_On)then
         SetDialogTitle ( DLG_MSG_INFORMATION, "Information" );
         MessageBox (szMsg,INFORMATION);
         abort; 
endif;

9.修改配置文件

#define CONFIGFILE "MyProject.config"
prototype WriteConfig(STRING);

function WriteConfig(ConnectionString)
STRING fileName;   
OBJECT configDoc, childNhib,childCon;
NUMBER  nResult;
begin
  nResult = 0; 
     set configDoc = CoCreateObject("MSXML.DOMDocument");
     fileName=TARGETDIR^CONFIGFILE;
     try
     if configDoc.Load(fileName) then
         set childNhib = configDoc.selectSingleNode("//configuration/hibernate-configuration/session-factory/property[@name='connection.connection_string']");
         set childCon = configDoc.selectSingleNode("//configuration/connectionStrings/add[@name='Default']/@connectionString");
         childNhib.text=ConnectionString;
         childCon.text=ConnectionString;
     endif;
        configDoc.save(fileName);
     catch
     nResult = -1;
     endcatch;    
  set configDoc = NOTHING;
  return nResult;
end;

10.向注册表runonce写入数据
//向runonce写入数据后,可在计算机下一次启动后执行相应的操作,下面的代码是在计算机启动后执行SRCDIR下的setup.exe程序

prototype NUMBER WriteRunOnce();

function NUMBER WriteRunOnce()
NUMBER nResult;
STRING szKey,szValue;
begin
 szValue = SRCDIR^"setup.exe"; 
 szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
 RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
 if (RegDBCreateKeyEx (szKey, "InstallQt") >= 0) then
  if RegDBSetKeyValueEx(szKey,"InstallQt",REGDB_STRING,szValue,-1) < 0 then
  return -1;
        endif;
    endif; 
    return  0;
end;

 用Installshield制作软件包常用的InstallScript---5

转载于:https://www.cnblogs.com/lanbo/archive/2009/08/26/Installshield12_4.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值