HOWTO:InstallShield脚本中如何启动某一程序

版权声明: 可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息。 

借着一个朋友要在安装包中启动Outlook的需求,写了一段代码,供有需要者参考。

这里先判断目标机是否安装了Office 2003 Outlook,之后启动。

function OnBegin()  
    
STRING svInstalledPath, szKeyRoot;
    
NUMBER nvSize, nType;
begin  
    
RegDBSetDefaultRoot HKEY_LOCAL_MACHINE ); 

    szKeyRoot = "SOFTWARE\\Microsoft\\Office\\11.0\\Outlook\\InstallRoot"
    nType = REGDB_STRING;
    
    
if (RegDBKeyExist (szKeyRoot) < 0then   
        
MessageBox ("RegDBKeyExist failed."SEVERE); 
    
else
        
if ( RegDBGetKeyValueEx (szKeyRoot, "Path", nType, svInstalledPath, nvSize) < 0 ) then
            
MessageBox ("RegDBGetKeyValueEx failed."SEVERE); 
        
else
            
LaunchAppAndWait(svInstalledPath + "Outlook.exe"""NOWAIT); 
        
endif;
    
endif;     
end;

一点分享,在用RegDBGetKeyValueEx读取数据时,在给入的第三个参数中,我直接给了REGDB_STRING,结果编译报错(error C8046),只好先定义了一个NUMBER类型的变量nType,然后将nType给入才通过了编译。

原文地址:https://www.cnblogs.com/wanbinghong/p/1872534.html