当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript winreg.keys函数代码示例

本文整理汇总了TypeScript中winreg.keys函数的典型用法代码示例。如果您正苦于以下问题:TypeScript keys函数的具体用法?TypeScript keys怎么用?TypeScript keys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了keys函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getMSDeployLatestRegKey

function getMSDeployLatestRegKey(registryKey: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    var regKey = new winreg({
      hive: winreg.HKLM,
      key:  registryKey
    })

    regKey.keys(function(err, subRegKeys) {
        if(err) {
            defer.reject(tl.loc("UnabletofindthelocationofMSDeployfromregistryonmachineError", err));
        }
        var latestKeyVersion = 0 ;
        var latestSubKey;
        for(var index in subRegKeys) {
            var subRegKey = subRegKeys[index].key;
            var subKeyVersion = subRegKey.substr(subRegKey.lastIndexOf('\\') + 1, subRegKey.length - 1);
            if(!isNaN(subKeyVersion)){
                var subKeyVersionNumber = parseFloat(subKeyVersion);
                if(subKeyVersionNumber > latestKeyVersion) {
                    latestKeyVersion = subKeyVersionNumber;
                    latestSubKey = subRegKey;
                }
            }
        }
        if(latestKeyVersion < 3) {
            defer.reject(tl.loc("UnsupportedinstalledversionfoundforMSDeployversionshouldbealteast3orabove", latestKeyVersion));
        }
         defer.resolve(latestSubKey);
    });
    return defer.promise;
}
开发者ID:colindembovsky,项目名称:vsts-tasks,代码行数:31,代码来源:msdeployutility.ts

示例2: _getToolRegKeyFromPath

    /**
     * Get resgistry key from path 
     * @param path  path of window registry
     * 
     * @returns     registry key   
     */
    private _getToolRegKeyFromPath(path: string): Q.Promise<string> {
        var defer = Q.defer<string>();
        var regKey = new winreg({
          hive: winreg.HKLM,
          key:  path
        });
    
        regKey.keys(function(err, subRegKeys) {
            if(err) {
                task.debug('Error during fetching registry key from path: '+ err);
                defer.reject(new Error(task.loc("UnableToFindMysqlFromRegistryOnMachineError", err)));
            }
            let resgistryKeyResult: string;
            if(subRegKeys){
                for(var index in subRegKeys) {
                    let subRegKey: string = subRegKeys[index].key;
                    if(subRegKey.match("MySQL Server")){
                        task.debug('Window mysql registry key: '+ subRegKey);
                        resgistryKeyResult = subRegKey;
                    }
                }
            }
            if(resgistryKeyResult){
                defer.resolve(resgistryKeyResult);
            }else{
                defer.reject(new Error(task.loc("UnableToFindMysqlFromRegistry")));
            }      
        });

        return defer.promise;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:37,代码来源:ToolPathOperations.ts


注:本文中的winreg.keys函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。