InstallShield技术概要

1.修改控制面板中显示的应用名称

     在打包脚本中填写以下信息  IFX_PRODUCT_NAME = "产品名称";就会在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall下对应GUID下修改DisplayName的值。

2.修改控制面板中显示的应用图标

    在General Information->Add or Remove Programs->Display Icon  后边填写图标的路径和名称。 

3.创建开始中的快捷方式   

    打开文件的快捷方式(图标默认是与文件的名称相同)

    AddFolderIcon( FOLDER_PROGRAMS ^ "路径", "名称", "路径+文件名称", "路径", "图标路径", 0, "", REPLACE );

    创建卸载快捷方式

    AddFolderIcon( FOLDER_PROGRAMS ^ "路径", "卸载", "", "", "图标路径", 0, "", REPLACE );

4.创建桌面快捷方式(图标默认是与文件的名称相同)

    AddFolderIcon( FOLDER_DESKTOP, "名称", "路径+文件名称", "路径", "图标路径", 0, "", REPLACE );

5.修改默认安装路径

    修改Installation Designer页面中的General Information中的TARGETDIR的值。

6.文件操作

    1)拷贝文件到系统目录

            CopyFile( SUPPORTDIR^"MUCam32.dll", WINSYSDIR^"MUCam32.dll");

            Disable(WOW64FSREDIRECTION);

            CopyFile( SUPPORTDIR^"MUCam32.dll",WINSYSDIR64^"MUCam32.dll");

    2)删除文件

            DeleteDir( szdbDirtt , ROOT );

7.支持多语言安装并能够弹出语言选择的界面

    在Project Assistant界面点击进入Installation Localization界面,选择支持的语言类型。

    默认创建的工程即使选择了安装支持的语言类型,在安装过程中也不会弹出选择语言的界面。要弹出语言选择的界面需要进行以下操作:

    点击Build下的Release Wizard...菜单项,会弹出对话框进行设置,一直点击下一步,直到Setup Languages页面,这里会显示你选择的支持语言类型,然后选中,并点击Make Default 按钮,然后设置默认选中的语言,然后一直点击下一步,直到完成就可以了。此时编译出的安装包就会在安装时提示选择安装语言。

8.获取用户安装时选择的语言类型

    用系统变量SELECTED_LANGUAGE进行判断,对应的是标识语言的数字。

9.ini文件操作

    1)获取某个字段的值        GetProfString ( szFileName, szSectionName, szKeyName, svResult );

    2)替换某个字段的值        ReplaceProfString ( szFileName, szSectionName, szKeyName, szOrigValue, szReplaceValue );

10.注册表操作

    1)创建注册表键值    RegDBCopyKeys ( szSourceKey, szTargetKey, nRootKeySource, nRootKeyTarget );或者RegDBCreateKeyEx ( szKey, szClass );

    2)  打开注册表键值    RegDBSetDefaultRoot ( nRootKey );

    3)删除注册表键值    RegDBDeleteKey ( szSubKey );

    4)修改注册表键值    RegDBSetKeyValueEx ( szKey, szName, nType, szValue, nSize );

11.在String Editor中添加的字串使用方式

    LoadStringFromStringTable ( szID, svString );

12.把安装程序打包到一个可执行文件中

    打开到Project Assistant页面点击Build Installation后,勾选Single Executable选项,点击Build Installations按钮。编译完成后点击Open release folder就可以看到编译后的文件。

13.系统变量

    BATCH_INSTALL 指示当传输文件采用LOCKEDFILE或SHAREDFILE时是否锁定文件
    CMDLINE Setup.exe传递的命令行参数
    COMMONFILES Common files全路径如“c:\program file\common files”
    ERRORFILENAME
    FOLDER_DESKTOP Windows 95 或Windows NT 4.0桌面folder的路径
    FOLDER_PROGRAMS Windows 95 或Windows NT 4.0 开始菜单中 开始\程序 的folder
    FOLDER_STARTMENU Windows 95 或Windows NT 4.0 开始菜单中 开始 的folder
    FOLDER_STARTUP Windows 95 or Windows NT 4.0 开始菜单中 启动 的folder
    INFOFILENAME InstallShield创建的备份文件全文件名
    ISRES _isres.dll全文件名
    ISUSER _isuser.dll全文件名
    ISVERSION 版本
    MEDIA 当前Media库名
    MODE 指示程序运行于normal还是silent模式
    PROGRAMFILES Windows 95 or Windows NT 4.0 “Program files” folder
    SELECTED_LANGUAGE 安装选择的语言号
    SRCDIR 安装源目录的全路径(此路径并不是setup.exe所在路径,而是安装过程中拷贝到临时文件下的路径)
    SRCDISK 安装源目录的盘符
    SUPPORTDIR 临时文件路径
    TARGETDIR 安装目的目录的全路径
    TARGETDISK 安装目的目录的盘符
    UNINST unInstallShield程序用的反安装文件全文件名
    WINDIR Windows的全路径(c:\windows)
    WINDISK Windows位于的盘符
    WINSYSDIR Windows\system的全路径(c:\windows\system)
    WINSYSDISK Windows\system位于的盘符

14.杀进程的方法

    szApplicationPath = WINSYSDIR^"taskkill.exe ";
    szApplicationCmdLine = "APP.exe";
    LongPathToQuote( szApplicationPath, TRUE );
    szCmdLine = szApplicationPath +  " " + "/f" + " " + "/im" + " " + "\"" + szApplicationCmdLine + "\"";
    LaunchAppAndWait ("", szCmdLine, WAIT);

15.进程控制

  

//
//
// Description: Windows NT process control functions.
//
//              The process code is adapted from code posted by William F.
//              Snodgrass to www.installsite.org. The original code header
//              is appended below. The array code is adapted from code posted
//              by Rajesh Ramachandran to the installshield.is6.installscript
//              newsgroup.
//
// Submitted by Richard Iwasa (riwasa@email.com).
//
// Usage example:
//
// if ProcessRunning("notepad") then
//  MessageBox("Application is running.", INFORMATION);
//
//  ProcessEnd("notepad");
//       
//      Delay(2);  // Delay to allow process list to refresh
//       
//  if ProcessRunning("notepad") then
//   MessageBox("Application is running.", INFORMATION);
//  else
//   MessageBox("Application is not running.", INFORMATION);
//  endif;
// else
//  MessageBox("Application is not running.", INFORMATION);
// endif;
//
// Original code header appended below:
//
// GetRunningApp();
// ShutDownApp();
//
// These script created functions will look for any running application
// based on the file name, then display an error message within the Setup.
// You can optionally halt the install or just continue on.
//
// You can use the ShutDownApp() function for shutting down that process
// or others as well. This is useful for processes that run in the
// background but have no Windows associated with them. May not work with
// Services.
//
// This script calls functions in PSAPI.DLL that are not supported on
// Windows 95 or 98.
//
// ***Instructions***
// Place these script peices into the Setup.rul file.
//
// Modify the script to include the applications you would like to get or
// shutdown.
//
// Submitted by William F. Snodgrass
// Contact info: bsnodgrass@geographix.com
//
// Created by Theron Welch, 3/3/99
// Minor modifications by Stefan Krueger, 11/03/99
//
// Copyright (c) 1999-2000 GeoGraphix, Inc.
//
//

 

/
// Function prototypes.
/

prototype POINTER ArrayToPointer(BYREF VARIANT);
prototype NUMBER  ProcessEnd(STRING);
prototype BOOL    ProcessRunning(STRING);

// Kernel functions.

prototype NUMBER Kernel32.OpenProcess(NUMBER, BOOL, NUMBER);
prototype NUMBER Kernel32.TerminateProcess(NUMBER, NUMBER);

// Process information functions.

prototype NUMBER PSAPI.EnumProcesses(POINTER, NUMBER, BYREF NUMBER);
prototype NUMBER PSAPI.EnumProcessModules(NUMBER, BYREF NUMBER, NUMBER,
  BYREF NUMBER);
prototype NUMBER PSAPI.GetModuleFileNameExA(NUMBER, NUMBER, BYREF STRING,
  NUMBER);

 

/
// Structures.
/

// Structure to mirror the C/C++ SAFEARRAY data structure.

typedef _SAFEARRAY
begin
 SHORT   cDims;
 SHORT   fFeatures;
 LONG    cbElements;
 LONG    cLocks;
 POINTER pvData;
 // rgsaBound omitted
end;

// Structure to mirror the C/C++ VARIANT data structure.

typedef _VARIANT
begin
 SHORT  vt;
 SHORT  wReserver1;
 SHORT  wReserved2;
 SHORT  wReserved3;
 NUMBER nData;
end;


  
/
// Constants.
/

#define PSAPI_FILE        "psapi.dll"  // Windows NT process DLL
#define PROCESSID_LENGTH  4            // 4 bytes (DWORD) for a process ID

// Process information constants.

#define PROCESS_QUERY_INFORMATION  0x400
#define PROCESS_ALL_ACCESS         0x1f0fff
#define PROCESS_VM_READ            0x10

 

//
//
// Function:    ArrayToPointer
//
// Description: Converts an InstallShield array into a C array.
//
//              When an array is created in InstallScript, a VARIANT variable
//              is created which holds an OLEAutomation SAFEARRAY. To pass
//              such an array to a DLL function expecting a C-style array,
//              this function explicitly typecasts the pointer to the array
//              to a _VARIANT pointer so that the _SAFEARRAY pointer can be
//              extracted. The pointer to the actual data is then extracted
//              from the _SAFEARRAY pointer.
//
// Parameters:  structArray - Array variable.
//
// Returns:     POINTER - Pointer to array.
//
//

function POINTER ArrayToPointer(structArray)
 _SAFEARRAY POINTER pstructArray;    // _SAFEARRAY array pointer
 _VARIANT   POINTER pstructVariant;  // _VARIANT array pointer
begin
 // Typecast the pointer to the array to a _VARIANT pointer.
 
 pstructVariant = &structArray;
 
 // Extract the _SAFEARRAY pointer from the _VARIANT.
 
 pstructArray = pstructVariant->nData;
 
 // Return the pointer to the actual data from the _SAFEARRAY.
 
 return pstructArray->pvData;
end;

 

//
//
// Function:    _Process_End
//
// Description: Terminates running processes for the specified application.
//
// Parameters:  szAppName - Name of the application to terminate.
//
// Returns:     >= 0 - Number of processes terminated.
//                -1 - Failure.
//
//

function NUMBER ProcessEnd(szAppName)
 NUMBER  nvReturn;           // Number of processes terminated
 NUMBER  nvProcessIDs(512);  // Array of process IDs
 NUMBER  nvBytesReturned;    // Number of bytes returned in process ID array
 NUMBER  nvProcesses;        // Number of processes running
 NUMBER  nvIndex;            // Loop index
 NUMBER  nvProcessHandle;    // Handle to a process
 NUMBER  nvModuleHandle;     // Handle to a process module
 NUMBER  nvBytesRequired;    // Number of bytes required to store values
 POINTER pvProcessIDs;       // Pointer to process ID array
 STRING  svModuleName;       // Module name
 STRING  svFileName;         // Module filename
begin
 // The psapi.dll reads the Windows NT performance database. The DLL
 // is part of the Win32 SDK.
 
 if UseDLL(WINSYSDIR ^ PSAPI_FILE) < 0 then
  // Could not load psapi.dll.
  
  MessageBox("ERROR: Could not load [" + WINSYSDIR ^ PSAPI_FILE +
    "].", SEVERE);
  
  return -1;
 endif;
   
    // Get the PIDs of all currently running processes.
   
 pvProcessIDs = ArrayToPointer(nvProcessIDs);

 EnumProcesses(pvProcessIDs, 512, nvBytesReturned);

 // Determine the number of process IDs retrieved. Each process ID
 // is PROCESSID_LENGTH bytes.
 
 nvProcesses = nvBytesReturned / PROCESSID_LENGTH;
 
 // Get the executable associated with each process, and check if
 // its filename matches the one passed to the function.
 
 for nvIndex = 1 to nvProcesses
  // Get a handle to the process. The OpenProcess function
  // must have full (all) access to be able to terminate
  // processes.
  
  nvProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION |
    PROCESS_ALL_ACCESS, 0, nvProcessIDs(nvIndex));
    
  if nvProcessHandle != 0 then
   // Get a handle to the first module in the process, which
   // should be the executable.
   
   if EnumProcessModules(nvProcessHandle, nvModuleHandle,  
     PROCESSID_LENGTH, nvBytesRequired) != 0 then
    // Get the path of the module.
    
    if GetModuleFileNameExA(nvProcessHandle, nvModuleHandle,
      svModuleName, SizeOf(svModuleName)) != 0 then
     // Extract the filename (without an extension) from
     // the path.
     
     ParsePath(svFileName, svModuleName, FILENAME_ONLY);

     if StrCompare(svFileName, szAppName) = 0 then
      // The process module matches the application
      // name passed to the function.
      
      if TerminateProcess(nvProcessHandle, 0) > 0 then
       nvReturn++;
      endif;
     endif;
    endif;
   endif;
  endif;
 endfor;
   
 if UnUseDLL(PSAPI_FILE) < 0 then
  MessageBox("ERROR: Could not unload [" + WINSYSDIR ^ PSAPI_FILE +
    "].", SEVERE);
    
  return -1;
 endif;
  
 return nvReturn;
end;

 

//
//
// Function:    _Process_Running
//
// Description: Determines if the specified process is running in memory.
//
// Parameters:  szAppName - Name of the application to check.
//
// Returns:     TRUE  - The process is running.
//              FALSE - The process is not running.
//
//

function BOOL ProcessRunning(szAppName)
 BOOL    bvRunning;          // Process is running
 NUMBER  nvProcessIDs(512);  // Array of process IDs
 NUMBER  nvBytesReturned;    // Number of bytes returned in process ID array
 NUMBER  nvProcesses;        // Number of processes running
 NUMBER  nvIndex;            // Loop index
 NUMBER  nvProcessHandle;    // Handle to a process
 NUMBER  nvModuleHandle;     // Handle to a process module
 NUMBER  nvBytesRequired;    // Number of bytes required to store values
 POINTER pvProcessIDs;       // Pointer to process ID array
 STRING  svModuleName;       // Module name
 STRING  svFileName;         // Module filename
begin
 // The psapi.dll reads the Windows NT performance database. The DLL
 // is part of the Win32 SDK.
 
 if UseDLL(WINSYSDIR ^ PSAPI_FILE) < 0 then
  // Could not load psapi.dll.
  
  MessageBox("ERROR: Could not load [" + WINSYSDIR ^ PSAPI_FILE +
    "].", SEVERE);
  
  return FALSE;
 endif;
   
    // Get the PIDs of all currently running processes.
   
 pvProcessIDs = ArrayToPointer(nvProcessIDs);

 EnumProcesses(pvProcessIDs, 512, nvBytesReturned);

 // Determine the number of process IDs retrieved. Each process ID
 // is PROCESSID_LENGTH bytes.
 
 nvProcesses = nvBytesReturned / PROCESSID_LENGTH;
 
 // Get the executable associated with each process, and check if
 // its filename matches the one passed to the function.
 
 for nvIndex = 1 to nvProcesses
  // Get a handle to the process.
  
  nvProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION |
    PROCESS_VM_READ, 0, nvProcessIDs(nvIndex));
    
  if nvProcessHandle != 0 then
   // Get a handle to the first module in the process, which
   // should be the executable.
   
   if EnumProcessModules(nvProcessHandle, nvModuleHandle,  
     PROCESSID_LENGTH, nvBytesRequired) != 0 then
    // Get the path of the module.
    
    if GetModuleFileNameExA(nvProcessHandle, nvModuleHandle,
      svModuleName, SizeOf(svModuleName)) != 0 then
     // Extract the filename (without an extension) from
     // the path.
     
     ParsePath(svFileName, svModuleName, FILENAME_ONLY);
     
     if StrCompare(svFileName, szAppName) = 0 then
      // The process module matches the application
      // name passed to the function.
      
      bvRunning = TRUE;
        
         goto ProcessRunningEnd;
     endif;
    endif;
   endif;
  endif;
 endfor;
   
 ProcessRunningEnd:
  
 if UnUseDLL(PSAPI_FILE) < 0 then
  MessageBox("ERROR: Could not unload [" + WINSYSDIR ^ PSAPI_FILE +
    "].", SEVERE);
    
  return FALSE;
 endif;
  
 return bvRunning;
end;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值