當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。