AutoSteel打包的代码部分

本文介绍了一个用于检测ProStructures软件安装路径的脚本函数GetRegPath(),该函数通过读取注册表来获取软件的安装目录,并根据不同版本的安装路径定制组件的安装位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GetRegPath函数

export prototype GetRegPath();

STRING installFileDir[MAX_PATH + 1];
 
LIST p_INSTALLPATH_List;
LIST p_PROGRAMPATH_List;
LIST p_WORKSPACEPATH_List;
NUMBER ProStructrualIndex;

function GetRegPath()
	LIST listSubKeys;      
	string szKey;  
	string keyValue;
	number nvSize;  
	number keyType;
	number nReturn;
	string listStringItem; 
begin   

	REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;
    p_INSTALLPATH_List = ListCreate(STRINGLIST);
    p_PROGRAMPATH_List = ListCreate(STRINGLIST);
    p_WORKSPACEPATH_List = ListCreate(STRINGLIST);
    listSubKeys = ListCreate(STRINGLIST); 
	RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
	nReturn  = RegDBQueryKey("SOFTWARE\\Bentley\\ProStructures", REGDB_KEYS, listSubKeys); 
	if (nReturn < 0) then    
		MessageBox("无法获取ProStructures安装路径", SEVERE);
		REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY;
		abort;
	else 
		nReturn = ListGetFirstString(listSubKeys,listStringItem);   
		while(nReturn != END_OF_LIST)
			if (StrFind(listStringItem, "{") < 0) then
			else
				szKey = "SOFTWARE\\Bentley\\ProStructures\\" + listStringItem;  
				keyType = REGDB_STRING;
				RegDBGetKeyValueEx(szKey, "InstallDir", keyType, keyValue, nvSize);
				ListAddString(p_INSTALLPATH_List,keyValue,AFTER);
				RegDBGetKeyValueEx(szKey, "ProgramPath", keyType, keyValue, nvSize);
				ListAddString(p_PROGRAMPATH_List,keyValue,AFTER);
				RegDBGetKeyValueEx(szKey, "ConfigurationPath", keyType, keyValue, nvSize);
				ListAddString(p_WORKSPACEPATH_List,keyValue,AFTER);
			endif;
			nReturn = ListGetNextString(listSubKeys, listStringItem);
		endwhile;
	endif;  
	     
	REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY;

end;
      
Setup.rul

//===========================================================================
//
//  File Name:    Setup.rul
//
//  Description:  Blank setup main script file
//
//  Comments:     Blank setup is an empty setup project. If you want to
//				  create a new project via. step-by step instructions use the
//				  Project Assistant.
//
//===========================================================================

// Included header files ----------------------------------------------------
#include "ifx.h"
#include "GetRegPath"
//---------------------------------------------------------------------------
// OnSetTARGETDIR
//
// OnSetTARGETDIR is called directly by the framework to initialize
// TARGETDIR to it's default value.
//
// Note: This event is called for all setups.
//---------------------------------------------------------------------------
function OnSetTARGETDIR()
number nId, nIgnore, nResult;
string szId, szTARGETDIR;
begin

    // In maintenance mode the value of TARGETDIR is read from the log file.
    if( MAINTENANCE ) then
        return ISERR_SUCCESS;
    endif;

    // Set TARGETDIR to script default.
    TARGETDIR = "<FOLDER_APPLICATIONS>\\<IFX_COMPANY_NAME>\\<IFX_PRODUCT_NAME>";
    // Read TARGETDIR from the media.
    nResult = MediaGetData( MEDIA, MEDIA_FIELD_TARGETDIR, nIgnore, szTARGETDIR );

    // Use the TARGETDIR from the media if anything was read.
    if( nResult >= ISERR_SUCCESS && StrLengthChars( szTARGETDIR ) ) then
        TARGETDIR = szTARGETDIR;
    endif;
        
	// Customize the default TARGETDIR for multi-instance application.
	// TODO: If you want something different customize the code below.	
	if( MAINT_OPTION = MAINT_OPTION_MULTI_INSTANCE  && MULTI_INSTANCE_COUNT > 0) then

		// Start with the current multi-instance count plus one.
		nId = MULTI_INSTANCE_COUNT + 1;

		// Find a unique TARGETDIR.
		while( ExistsDir( TARGETDIR ) = EXISTS )
			
			// Convert to string.
			NumToStr( szId, nId );
			
			// Update IFX_MULTI_INSTANCE_SUFFIX
			IFX_MULTI_INSTANCE_SUFFIX = "_" + szId;
		
			// Update TARGETDIR
			TARGETDIR = TARGETDIR + IFX_MULTI_INSTANCE_SUFFIX;
			
			// Update nId
			nId = nId + 1;

		endwhile;

	endif;

end;

//---------------------------------------------------------------------------                                                                        
// OnFirstUIBefore
//
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
    number  nResult, nLevel, nSize, nSetupType;
    string  szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
    string  szName, szCompany, szTargetPath, szDir, szFeatures, svParentPath;
    STRING szText1,szText2,szText3,szText4;
    NUMBER nvCheck1,nvCheck2,nvCheck3,nvCheck4;
    BOOL    bLicenseAccepted;
begin	

    // Added in InstallShield 15 - Show an appropriate error message if
    // -removeonly is specified and the product is not installed.
    if( REMOVEONLY ) then
        Disable( DIALOGCACHE );
		szMsg = SdLoadString( IDS_IFX_ERROR_PRODUCT_NOT_INSTALLED_UNINST );
   		SdSubstituteProductInfo( szMsg );
		MessageBox( szMsg, SEVERE );
		abort;
    endif;
   
    nSetupType = COMPLETE;	
    szDir = TARGETDIR;
    szName = "";
    szCompany = "";
    bLicenseAccepted = FALSE;

// Beginning of UI Sequence
Dlg_Start:
    nResult = 0;

Dlg_SdWelcome:
    szTitle = "";
    szMsg = "";
    //{{IS_SCRIPT_TAG(Dlg_SdWelcome)
    nResult = SdWelcome( szTitle, szMsg );
    //}}IS_SCRIPT_TAG(Dlg_SdWelcome)
    if (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense2:
    szTitle = "";
    szOpt1 = "";
    szOpt2 = "";
    //{{IS_SCRIPT_TAG(License_File_Path)
    szLicenseFile = SUPPORTDIR ^ "License.rtf";
    //}}IS_SCRIPT_TAG(License_File_Path)
    //{{IS_SCRIPT_TAG(Dlg_SdLicense2)
    nResult = SdLicense2Ex( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted, TRUE );
    //}}IS_SCRIPT_TAG(Dlg_SdLicense2)
    if (nResult = BACK) then
        goto Dlg_SdWelcome;
    else
        bLicenseAccepted = TRUE;
    endif;
// 我的改动:注释了Dlg_SdRegisterUser分支
/*
Dlg_SdRegisterUser:
    szMsg = "";
    szTitle = "";
    //{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)	
    nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
    //}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
    if (nResult = BACK) goto Dlg_SdLicense2;

Dlg_SetupType2:   
    szTitle = "";
    szMsg = "";
    nResult = CUSTOM;
    //{{IS_SCRIPT_TAG(Dlg_SetupType2)	
    nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
    //}}IS_SCRIPT_TAG(Dlg_SetupType2)
    if (nResult = BACK) then
        goto Dlg_SdLicense2;
    else
        nSetupType = nResult;
        if (nSetupType != CUSTOM) then
            szTargetPath = TARGETDIR;
            nSize = 0;
            FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
            if (nSize != 0) then      
                MessageBox( szSdStr_NotEnoughSpace, WARNING );
                goto Dlg_SetupType2;
            endif;
        endif;   
    endif;
	
Dlg_SdAskDestPath2:
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
	szTitle = "";
    szMsg = "";
    if (nSetupType = CUSTOM) then
                //{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)	
		nResult = SdAskDestPath2( szTitle, szMsg, szDir );
                //}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
        TARGETDIR = szDir;
    endif;
    if (nResult = BACK) goto Dlg_SetupType2;

Dlg_SdFeatureTree: 
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
    szTitle = "";
    szMsg = "";
    szFeatures = "";
    nLevel = 2;
    if (nSetupType = CUSTOM) then
        //{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)	
        nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
        //}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
        if (nResult = BACK) goto Dlg_SdAskDestPath2;  
    endif;    
    */

	GetRegPath();
	if(ListCount(p_PROGRAMPATH_List)<=0) then
		MessageBox ("ProStructures Connect安装路径寻找失败,无法安装", SEVERE);
    	abort;
	endif;
    
Dlg_AskOptions:
	szMsg      = "请选择在哪个版本的ProStructures上安装";
	
	//read myList from first Item
	ListGetFirstString(p_PROGRAMPATH_List,svParentPath);
    szText1 = svParentPath;
    nvCheck1 = TRUE;
    if(ListCount(p_PROGRAMPATH_List)>1) then
    	ListSetIndex (p_PROGRAMPATH_List, 1);
    	ListCurrentString(p_PROGRAMPATH_List,svParentPath);
    	szText2 = svParentPath;
    	nvCheck2 = FALSE;
    endif;
    if(ListCount(p_PROGRAMPATH_List)>2) then
    	ListSetIndex (p_PROGRAMPATH_List, 2);
    	ListCurrentString(p_PROGRAMPATH_List,svParentPath);
    	szText3 = svParentPath;
    	nvCheck3 = FALSE;
    endif;
    if(ListCount(p_PROGRAMPATH_List)>3) then
    	ListSetIndex (p_PROGRAMPATH_List, 3);
    	ListCurrentString(p_PROGRAMPATH_List,svParentPath);
    	szText4 = svParentPath;
    	nvCheck4 = FALSE;
    endif; 
    
    nResult = NEXT;
    if(ListCount(p_PROGRAMPATH_List)=1) then
    	nResult = AskOptions( EXCLUSIVE, szMsg,szText1,nvCheck1);
    endif;
    if(ListCount(p_PROGRAMPATH_List)=2) then
    	nResult = AskOptions( EXCLUSIVE, szMsg,szText1,nvCheck1,szText2,nvCheck2);
    endif;
    if(ListCount(p_PROGRAMPATH_List)=3) then
    	nResult = AskOptions( EXCLUSIVE, szMsg,szText1,nvCheck1,szText2,nvCheck2,szText3,nvCheck3);
    endif;
    if(ListCount(p_PROGRAMPATH_List)>3) then
    	nResult = AskOptions( EXCLUSIVE, szMsg,szText1,nvCheck1,szText2,nvCheck2,szText3,nvCheck3,szText4,nvCheck4);
    endif;
	if( nResult = BACK ) then
    	goto Dlg_SdLicense2;
    endif;
    
    ProStructrualIndex=0;
    if((nvCheck2=TRUE)&&ListCount(p_PROGRAMPATH_List)>1) then
    	ProStructrualIndex=1;
    endif;
    if((nvCheck3=TRUE)&&ListCount(p_PROGRAMPATH_List)>2) then
    	ProStructrualIndex=2;
    endif;
    if((nvCheck4=TRUE)&&ListCount(p_PROGRAMPATH_List)>3) then
    	ProStructrualIndex=3;
    endif;
    //设定安装路径
    ListSetIndex (p_PROGRAMPATH_List, ProStructrualIndex);
    ListCurrentString(p_PROGRAMPATH_List,svParentPath);
    svParentPath = svParentPath ^ "Assemblies\\";
    ComponentSetTarget(MEDIA,"<AssembliesDir>",svParentPath);
    //MessageBox (svParentPath, SEVERE);    
    
    ListSetIndex (p_WORKSPACEPATH_List, ProStructrualIndex);
    ListCurrentString(p_WORKSPACEPATH_List,svParentPath);
    svParentPath = svParentPath ^ "Organization\\Dgnlib\\Gui\\";
    ComponentSetTarget(MEDIA,"<DgnlibDir>",svParentPath);
    //MessageBox (svParentPath, SEVERE);
    

Dlg_SQLServer:
    nResult = OnSQLServerInitialize( nResult );
    if( nResult = BACK ) goto Dlg_AskOptions;

Dlg_ObjDialogs:
    nResult = ShowObjWizardPages( nResult );
    if (nResult = BACK) goto Dlg_SQLServer;
  
Dlg_SdStartCopy2:
    szTitle = "";
    szMsg = "开始安装AutoSteel";


    //{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)	
    nResult = SdStartCopy2( szTitle, szMsg );	
    //}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
    if (nResult = BACK) goto Dlg_ObjDialogs;

    // Added in 11.0 - Set appropriate StatusEx static text.
    SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
 
    return 0;
end;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值