Intallshield 如何遍历全盘与更新文件

最近我们做的产品遇到这个问题:客户没有将原来的版本删除干净,导致安装新版本的时候查找dll文件的时候发生调用错误。我没有去追查windows是如何查找 dll 文件的,但确实出现了错误的调用。所以决定在安装新版本的时候遍历全盘把原来的dll文件替换掉。其实相对来说比较简单,但对于刚入门的菜鸟来说当时的确难为到了我。所以在做的过程中总计了一些自己认为有些参考价值的东西。

1. 本来打算自己画一个对话框的,但那样的确太过麻烦。所以改了下 AskOptions() 的 Title.

    SetDialogTitle (DLG_ASK_OPTIONS, "Search And Update Client Components/n      Select the actions of the following options");

 

2. 遍历整个硬盘,搜索要更新的文件。

 function DoUpdateDll() 

STRING svResult, szServerPath,svString, strtemp; 

LIST listID;  

NUMBER temp,nResult;

begin

     SetStatusWindow( 1, "" );

Enable( STATUSEX );

SetStatusWindow( 60, "");    //输入提示内容

CreateInstallationInfo();  

    listID = ListCreate(STRINGLIST);

GetValidDrivesList( listID, FIXED_DRIVE, 10 ); 

       nResult = ListGetFirstString (listID, svString);     

       while( nResult !=END_OF_LIST )

         strtemp = svString;

              strtemp=strtemp+"://"; ;

         DoFindAndReplaceFiles( strtemp, "" );   //“” 中为要更新的文件名

   DoFindAndReplaceFiles( strtemp, "");

  DoFindAndReplaceFiles( strtemp, "");

  DoFindAndReplaceFiles( strtemp, "");

 nResult = ListGetNextString (listID, svString); //得到下一个硬盘

  endwhile; 

     SetStatusWindow( 100, "");  //进度条显示满格,查找替换完成

     Delay( 2 );    

     Disable( STATUSEX );

     ListDestroy( listID);    

     MessageBox( "", WARNING );   //输入提示内容

 end;         

 

 //查找替换程序

 function DoFindAndReplaceFiles(strtemp,filename)

  STRING svResult, szServerPath;

  NUMBER nResultTmp;

 begin     

    szServerPath = TARGETDIR ^ "";   //“” 中为你的程序默认的安装路径, TARGETDIR是更改后的路径

    szServerPath = szServerPath + filename;

  nResultTmp = FindAllFiles( strtemp, filename, svResult, RESET );   //可以参照 FIndAllFiles() 函数来看。

  while( nResultTmp>=0 )

  CopyFile( szServerPath, svResult );  

  nResultTmp = FindAllFiles( strtemp, filename, svResult, CONTINUE );

  endwhile; 

FindAllFiles(strtemp, filename, svResult, CANCEL );// 这句要小心,不能遗漏。

 end;     

 

以上的一些可能还存在不少可以改进的地方,希望老鸟指导。有些东西不会,不用怕,总能找到解决的方法。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值