[转]用Installshield制作软件包常用的InstallScript--4
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;