Installshield 2008 And 脚本 (九 )

卸载操作

安装的过程中我在OnAfterFirstUI中做了一些操作:

拷贝文件,注册Filter,安装驱动,创建卸载快捷方式

那么我在卸载的时候也要做反向的对应操作:

删除卸载快捷方式,卸载虚拟驱动,反注册Filter,删除文件。

知道安装时候句柄函数调用顺序:

OnFirstUIBefort ----> OnMoveData  -----> OnFirstUIAfter;

Maintance时候调用顺序:

OnMaintUIBefort ----> OnMoveData ----> OnMaintUIAfter

安装时候自己控制的操作多数在UIAfter后面做,卸载的时候有些操作必须在OnMoveData前面做。即删除拷贝的文件前面做。

那么我们在OnMaintUIBefore里面卸载虚拟驱动,反注册Filter,因为这些还依赖于安装路径里面的一些文件。

function OnMaintUIBefore()

    number	nResult, nType, nMediaFlags;

    string	szTitle, szMsg, szIgnore;  

    STRING szCommandLine, szSourceFilePath, szTargetFilePath, szPath; 

begin

      

         ..................................................

     / Show Uninstall Confirmation Dialog

     if ( nType = REMOVEALL ) then

		nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO );

		if (nResult != IDYES ) then

            /

            // unregister the filter

            szPath = TARGETDIR;

		    szSourceFilePath = "regsvr32.exe";      

		    szTargetFilePath = szPath ^ "AZImageProcess.ax";    

			SetFileInfo(szTargetFilePath,FILE_ATTRIBUTE,FILE_ATTR_NORMAL,"");	

			ChangeDirectory(szPath);

			LongPathToShortPath  ( szTargetFilePath );

			szCommandLine = "/u"+szTargetFilePath;             

			LaunchAppAndWait ( szSourceFilePath , szCommandLine , WAIT ); 

			Delay(1);

           /



.        ...........................................................................



Dlg_ObjDialogs:

    nResult = ShowObjWizardPages( nResult );

    if ( ( nResult = BACK ) && ( nType != MODIFY ) ) goto Dlg_Start;

    if ( ( nResult = BACK ) && ( nType = MODIFY ) ) goto Dlg_SdFeatureTree;



switch(nType)



        case REMOVEALL: 

       

            // uninstall virtual driver

            

            szPath = TARGETDIR^ "Virtual Cam Driver";

		    szSourceFilePath = szPath^ "VDrvInst.exe";      

		    szTargetFilePath = szPath^ "ECamVideo.inf";	

				                               

			LongPathToShortPath  ( szSourceFilePath );	                               

			LongPathToShortPath  ( szTargetFilePath );

			szCommandLine = "/u";             

			LaunchAppAndWait ( szSourceFilePath , szCommandLine , WAIT ); 

			

			Delay(5);

     //

...........................................................................

end;

上面代码中位于/之间的是我自己修改的,其他是自动生成的代码。

卸载的操作要加载到正确的地方。

OnMaintUIAfter函数里面的操作:删除一些已经存在的目录文件

删除Startmenu里面的Azurewave Folder,需要自己删除的理由:因为自己写代码添加了Uninstall 快捷方式,如果不用代码删除那么这个Uninstall方式在卸载完后,还存在于StartMenu目录里面。

/

	// remove all the copy files    

	// Delete the install files

    szTargetPath = PROGRAMFILES ^ COMPANY_NAME;   

    DeleteDir(szTargetPath, ALLCONTENTS); 

//

删除安装路径路径和文件,自己写代码删除可以删除的更干净,保护没有自动删除干净的措施。

  ///

         // delete the shortcut in the start menu/programes     

          szTargetPath = FOLDER_PROGRAMS ^ COMPANY_NAME;  

         DeleteDir(szTargetPath, ALLCONTENTS); 

  ///

这样自己控制的卸载操作就完成了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值