InstallShield12制作的安装包,安装程序中途退出时,调用Exit,可能安装进程并不会退出,然后再次运行时就会出现错误提示:“已存在一个安装进程”。
该问题的解决方案为:复写OnCanceling函数,将原处理函数中的abort修改为Exit。
如下:
//---------------------------------------------------------------------------
// OnCanceling
//
// The OnCanceling event is sent when the installation is cancelled,
// usually as result of end user clicking Cancel button of a dialog or
// pressing Esc key. Calling Do(EXIT) will also trigger this event.
//---------------------------------------------------------------------------
function OnCanceling()
STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
NUMBER bvOpt1, bvOpt2;
begin
if (IDYES = SprintfBox(MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2, SdLoadString(SD_STR_ONCANCELING_TITLE), SdLoadString(SD_STR_ONCANCELING_CONFIRM_MSG))) then
//Close the current dialog.
EndCurrentDialog();
//Display Finish dialog.
szTitle = "";
szMsg1 = SdLoadString( SD_STR_ONCANCELING_FINISH_MSG1 );
szMsg2 = SdLoadString( SD_STR_ONCANCELING_FINISH_MSG2 );
szOpt1 = "";
szOpt2 = "";
bvOpt1 = FALSE;
bvOpt2 = FALSE;
SdFinish ( szTitle, szMsg1, szMsg2 , szOpt1, szOpt2, bvOpt1, bvOpt2 );
//将ABORT修改为EXIT以退出
//abort;
Exit;
endif;
end;