Install Shiled 实现应用程序的开机启动

最近遇到需要实现某个应用程序开机自动启动的功能,在网上查了一些资料,大概有两种方法:

1.通过写注册表来实现

参考一下代码:

在installshield中写注册表,让应用程序开机启动    

///
//                                                                            //
// Function: SetupRegistry                                                    //
//                                                                            //
//   Purpose: This function makes the registry entries for this setup.         //
//                                                                            //
///
function SetupRegistry()
NUMBER nResult;
STRING     szPath3;
STRING     szResult;

begin

   // TODO : Add all your registry entry keys here
   //
   //
   //     RegDBCreateKeyEx, RegDBSetKeyValueEx....
   //

   //nResult = CreateRegistrySet( "" );


   if(FindFile(TARGETDIR,"Sanc.exe",szResult)=0)    then
       szPath3=TARGETDIR^"Sanc.exe";
       LongPathToQuote(szPath3,TRUE);
       RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
       nResult=RegDBSetKeyValueEx("SOFTWARE//Microsoft//Windows//CurrentVersion//Run","Sanc",REGDB_STRING,szPath3,-1);
   endif;

   return nResult;
end;

 

还有一个问题就是想实现界面上Checkbox选择是否要开机启动,关键是实现一个checkbox,参考以下代码:

Disable(STATUSEX);

ShowObjWizardPages(NEXT);

bOpt1 = TRUE;

bOpt2 = TRUE;

szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);

szTitle="";

szMsg1="";

szMsg2="";

szOption1="Show Readme";

szOption2="Create Shortcut on Desktop";

SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);

 

写注册表的方式,在卸载时可正常的卸载掉开机启动的功能,但是用户不能在启动项中将该功能删除,

2.在启动文件夹中创建应用程序的启动快捷方式

可以在Shortout中直接建立这个快捷方式,无需编程;

但实现用户点选checkbox的方式,可写script,可使用AddFolderIcon实现快捷方式的建立,可参考:

AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir, szIconPath, nIcon, szShortCutKey, nFlag);

/**//*--------------------------------------------------------------*

 *

 * InstallShield Example Script

 *

 * Demonstrates the AddFolderIcon function.

 *

 * This example places a shortcut to an executable file on the

 * Start menu and the Start Programs menu.

 *

 * Note: Before running this script, set the preprocessor

 *       constants so that they reference the fully-qualified

 *       names of the Windows Notepad executable and a valid

 *       text file on the target system.

 *

*--------------------------------------------------------------*/

 

#define PROGRAM "C:/Windows/Notepad.exe"

#define PARAM   "C:/Windows/Readme.txt"

 

 STRING szProgramFolder, szItemName, szCommandLine, szWorkingDir, szIconPath;
 
 STRING szShortCutKey, szProgram, szParam;
 
NUMBER nIcon;
  


#include "ifx.h"

program

 

// Set up parameters for call to AddFolderIcon.
  
 szProgramFolder = FOLDER_STARTMENU;
 
 szItemName      = "Notepad Example 1";
 


szProgram = PROGRAM;
  
szParam   = PARAM;
  
LongPathToQuote (szProgram, TRUE);
  
LongPathToShortPath (szParam);
  


 szCommandLine = szProgram + " " + szParam;
 


 szWorkingDir  = "";
 
 szIconPath    = "";
 
 nIcon         = 0;
 
szShortCutKey = "";
  


 // Add a shortcut to the Start menu.
 
 if (AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir,
 
 szIconPath, nIcon, szShortCutKey, REPLACE) < 0) then
                    
MessageBox ("AddFolderIcon failed.", SEVERE);
     
else
  
 SprintfBox (INFORMATION, "AddFolderIcon", "%s created successfully.",
    
szItemName);
                 
 endif;
 


 szProgramFolder = "";
 
szItemName    = "Notepad Example 2";
  


// Add a shortcut to the Programs menu.
  
if (AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir,
  
 szIconPath, nIcon, szShortCutKey, REPLACE) < 0) then
                    
MessageBox ("AddFolderIcon failed.", SEVERE);
     
else
  
SprintfBox (INFORMATION, "AddFolderIcon", "%s created successfully.",
     
szItemName);
                 
  endif;
 
endprogram


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/leon_founder/archive/2006/08/21/1102447.aspx

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
请解释下列代码finish /clear !前处理 /title,shiled tunnel /nopr keyw,pr_set,1 keyw,pr_struc,1 /com /com,preferences for GUI filtering have been set to display: /com,structural !定义材料及相关物理量 /prep7 et,1,beam3 !用bean3模拟衬砌 et,2,link10 !用link10模拟弹簧 keyopt,2,3,1 !使弹簧只受压不受拉,因此无需删除弹簧 R,1,0.525,0.005359,0.35 !输入管片常数,从第二个数字依次是截面面积、惯性矩、管片厚度 R,2,1 mp,ex,1,34.5e9 !弹性模量 mp,prxy,1,0.2 !泊松比 mp,dens,1,2500 !密度 mp,ex,2,5e7 mp,prxy,2,0.2 !建立圆环 k,1000,0,0,0 circle,1000,2.95 !2.95是管片半径 Lsel,all LESIZE,all,0.5, , , , , , ,1 Type,1 Mat,1 Real,1 Lmesh,all !建立弹簧 CSYS,1 wpcsys,-1 nsel,s,loc,x,3,4 !选择半径3到4的点进行复制 NGEN,2,100,all, , ,1 , , ,1, !选择半径3到4的点进行复制 allsel,all *do,i,1,40 type,2 real,2 mat,2 e,i,i+100 !弹簧命令 *enddo !施加约束 nsel,s,loc,x,3.5,4.5 !约束半径3.5到4.5的点的所有位移 d,all,all !约束圆环左右端点的竖向位移,上下端点的水平位移 nsel,s,,,22 D,all, , , , , ,UX, , , , , nsel,s,,,2 D,all, , , , , ,UX, , , , , nsel,s,,,12 D,all, , , , , ,UY, , , , , nsel,s,,,1 D,all, , , , , ,UY, , , , , allsel,all csys,0 wpcsys,-1 /solu acel,0,7.5,0 !施加自重荷载 !在此位置施加计算得到的等效节点荷载 !计算 esel,,,,1,40,1 !选择单元1到40进行查看,忽略弹簧 solve !绘制内力表 ETABLE,NI,SMISC,1 ETABLE,NJ,SMISC,7 ETABLE,QI,SMISC,2 ETABLE,QJ,SMISC,8 ETABLE,MI,SMISC,6 ETABLE,MJ,SMISC,12
最新发布
05-25

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值