installshield学习笔记

看预定义常量的值:SprintfBox(INFORMATION,"","%d",变量值);
 
 
自定义常量:#define MAXCOUNT 1000;#define COMPAN_NAME "Example_Company";
 
 
所有用prototype声明过的函数都必须在函数块中定义,
 
 
 
在预处理语句后面不带“;”例如:#define,#include等等;
关键字program,endprogram和end和begin
 
 
获取c盘空间大小的脚本
#define DISK_DRIVE "C:\"
STRING szDrive,svString;
NUMBER nSpace,nResult;
 
szDrive = DISK_DRIVE;
nSpace = GetDiskSpace(szDrive);
 
nResult = NumberToStr(svString,nSpace);
if(nResult < 0) then
   MessageBox("NumToStr failed.",SERVE);
   abort;
endif;
 
SprintfBox(INFORMATION,"info","Disk space:%s",svString);
 
 
操作符说明:
加入路径操作符(^)该操作符用于将路径加入到路径描述或文件名描述中去。
当你想把两条路径或者和一个文件名连接到一起时,可以使用加入路径(^)操作符
。当把一个文件名或者一个子目录加入到路径中时,该操作符会自动检查是否有足够
数量的反斜杠符号:
szStringVar = “c:\MYPATH\”^";
 
 
查找字符串(%):使用字符串操作符(%)可以确定一个字符串是否是另外一个字符串的字串。字符串操作符是不区分大小写的。
szStringVarA = "This is a sample string.";
if(szStringVarA %"sample"//SAMPLE大小都可以的) then
   MessageBox("操作完成","");和
endif;
 
函数:
AskYesNo("Installation Complete.Would you like to view the ReadMe file Now?",YES);//默认的选择的是yes哦
 
当安装脚本遇到abort语句时,安装程序就会终止。然后卸载过程就会在后台自动运行去回滚未完成的安装,并删除那些已经安装的并在安装脚本中
等级的文件。当用户在安装过程中按下Esc键、F3键或者安吉对话框中的Cancle按钮时,安装程序就会调用默认的退出事件的处理句柄,在这里也用到了abort语句。
 
 
for循环
 
for iCount = 1 to 10
MessageBox("you 1 see this 10 times",INFORMATION);
endfor;
 
降序for循环
for j = 20 downto 10 step 5//20,15,10
MessageBox("you will seee this three times",INFORMATION);
endfor;
 
步长:
for iCount = 10 to 100 step 10
MessageBox("you 1 see this 10 times",INFORMATION);
endfor;
 
Goto:
关键字goto用于将程序直接跳转到指定标号的那个分支行去。在下面的代码段中,goto语句可以使程序直接跳转到标号name所指定的那一行去。
Name:
 AskText("Company name :","",szSrc);
if(szSrc = "") then
MessageBox("Place enter the company name.",SERVE);
goto name;
endif;
在主程序中声明的标号,只能goto到主程序中的goto标号中,在函数中声明的goto语句只走到函数中的goto语句
 
 
安装完毕重启代码:
在After Move Data--->OnEnd函数里面
function OnEnd()
begin
SdFinishReboot ("title", "haha", 0, "oooo", 0);//第二个参数必须为数字零现在还不允许有其他的值哦
end;
 
 
RegDBSetDefaultRoot(HEKY_LOCAL_MACHINE);注册表的根节点
 
 
abort和exit 的区别:
 
都是退出安装过程,区别是abort有回滚过程,而exit则只是结束安装过程,对之前的操作不做任何回滚动作。
 
 
改变对话框标题的installshield ward的方法:SetTitle(IFX_PRODUCT_NAME, 0, BACKGROUNDCAPTION);是在onBegin方法里面增加这一条。
 
 
函数的执行顺序:
Before Move Data        OnBegin
Before Move Data        OnFirstUIBefore
Before Move Data        OnMaintUIBefore
 
 
 
Move Data            OnMoved
 
 
 
After Move Data         OnFirstUIAfter
After Move Data         OnMaintUIAfter
 
 
 
函数的执行顺序
InstallShied2008的函数执行顺序如下:
OnBegin ---> OnShowUI
OnShowUI里面为:
OnFirstUIBefore ----> OnMoveData ------> OnFirstUIAfter
OnFirstUIBefore (include): 欢迎界面, 选择安装路径, 安装的类型(这个界面已经却掉) .
OnMoveData(include): 文件的拷贝
OnFirstUIAfter(include): FileAttribute, Modify registration, create shortcut, register filter/com, excute custom exe;
第二次运行Setup的时候:(维护,一般会出现我们所看见的Repair、Modify、Delete三个选项)
OnMainUIBefore ---> OnMoveData ----> OnMainUIAfter 
 
改变内部对话框的标题栏的图片的方法:首先需要将bmp格式(尺寸大小为499*58像素点)文件添加到Support Files/Language Independent目录下
 之后在事件响应函数OnBegin中添加如下代码:
DialogSetInfo(DLG_INFO_ALTIMAGE, SUPPORTDIR ^ "Bear_Banner.bmp", TRUE);
 
 
****************************************************************填写注册码代码分支*******************************************************
Dlg_AskRegisterCode://注册码填写dialog
   
    SetDialogTitle (DLG_ASK_TEXT, "注册码验证:请输入正确的验证码");
    nResult = AskText ("注册码:", szRegisterCode, szRegisterCode);
    if (nResult = BACK) then 
     
        goto Dlg_SdLicense2;
    endif;
    
    if(szRegisterCode = "") then 
       MessageBox("注册码不能为空",SEVERE);
       goto Dlg_AskRegisterCode;
    endif;
    if(StrLengthChars(szRegisterCode) != 16) then
       MessageBox("请输入正确的注册码",SEVERE);
       szRegisterCode = "";
       goto Dlg_AskRegisterCode;
    endif;
       
    if(StrLengthChars(szRegisterCode) = 16) then
       SdShowMsg("正在验证中.....",TRUE);
       Delay(3);
       SdShowMsg("正在验证中.....",FALSE);
       MessageBox("联网验证失败!程序将会稍后验证....",INFORMATION);
       bRegisterCodeChecked = TRUE; 
       //将注册码保存到安装目录下的 文件中 
       //文件名为:
       OpenFileMode (FILE_MODE_APPEND); 
       if(ExistsDir(szDir) = NOTEXISTS) then
           CreateDir(szDir); 
       endif; 
       if(CreateFile (nvFileHandle, szDir,"") < 0) then
          MessageBox("注册码文件创建失败!",SEVERE);
       else
         if(WriteLine(nvFileHandle, szRegisterCode) < 0) then
         MessageBox("注册码保存失败",SEVERE);
         endif;
       endif;
       CloseFile(nvFileHandle);
       goto Dlg_AskPlatformServerIP;
    endif; 
 
****************************************************************填写注册码代码分支*******************************************************
学习博客:
http://www.cnblogs.com/BeyondTechnology/category/265153.html
 
 
***************************************************************安装完成以后不在控制面板里面显示卸载图标**********************************
function OnEnd()
 string subKey;
begin
subKey = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + PRODUCT_GUID;    
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBKeyExist(subKey) =1) then
RegDBDeleteKey (subKey);   //不在控制面板的添加删除程序中显示。
endif;  
if(!ExistsDir(DISK1TARGET)) then
DeleteDir(DISK1TARGET,ALLCONTENTS);//去掉卸载功能。
endif;
end;
 
 
或者:
 
Installation Designer->Media->Releases: 选择要设置的release项,
 
在右边的参数列表中 Hide Add/Remove Panel Entry(最后一项),设置为yes
 
 
***************************************************************安装完成以后不在控制面板里面显示卸载图标**********************************
  
 
 
 
 
 
 
***************************************************************隐藏初始化界面的方法******************************************************
在InstallShield制作的安装包中,可以通过参数hide_progress隐藏启动初始界面,但工程不同,应用方法不同:
 
InstallScript工程:
设置方法:在Installation Designer-> Media -> Releases -> Release * -> Setup.exe选项卡中,Setup Command Line属性项中加上“/hide_progress”
 
***************************************************************隐藏初始化界面的方法******************************************************2013/3/18
 
问题:
1/创建快捷键的图标
2/创建卸载的图标
3/自定义欢迎前面的窗口的设置
4/设置窗体标题行最右边的图标
5/设置窗体标题栏下方,右侧的背景图
 
 
Dlg_SetupType2
原文地址:https://www.cnblogs.com/lizhenlin/p/6287301.html