Install Shield 中判断安装还是卸载

如果在安装过程中写了一段InstallScript安装脚本,发现在卸载时也执行了这一段代码,而且也遇到过卸载时自定义需求的情况,于是在网上找了很久,没有发现好用的。后来在国外一个论坛里发现一个突破点,自己研究了一下,竟然发现下面InstallScript代码可以区别当前执行的是安装还是卸载过程。不多说了,代码如下:

function CheckInstallStatus(hMSI)
    string sRemove;
    number nBuffer;
begin 
    nBuffer = 256;
    if (MsiGetProperty(hMSI, "REMOVE", sRemove, nBuffer) = ERROR_SUCCESS) then
        if (sRemove = "") then
            MessageBox("This is INSTALL status", 0);
        else
            if (sRemove = "ALL") then
                MessageBox("This is UNINSTALL status", 0); 
            endif;
        endif;
    endif;
end;

原文地址:https://www.cnblogs.com/cxun/p/1709284.html