本文整理匯總了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;
}
示例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;
}