Monitor Window Registry Key value change ashynchronously Javascript
Here is sample code to monitor registry value change without hanging the thread.
Its sample code so use properly.
var g_DefaultTimeOutForRegMonitoring = 15000;
MonitoRegistryValue: function (szRegKeyVal, val) { // Key value path and value to watch
var intervalID;
var regKey = szRegKeyVal;
var value = val;
intervalID = setInterval(function (regKey, value) {
try {
var ret;
ret = g_objRegUtil.ReadValueFromRegistry(szRegKeyVal);
if (ret == value)
// Check ret value and make decision
}
} catch (err) {
}
}, 5);
// We will wait for certain time else break the watch
setTimeout(function () {
clearInterval(intervalID);
}, g_DefaultTimeOutForRegMonitoring);
}
Its sample code so use properly.
var g_DefaultTimeOutForRegMonitoring = 15000;
MonitoRegistryValue: function (szRegKeyVal, val) { // Key value path and value to watch
var intervalID;
var regKey = szRegKeyVal;
var value = val;
intervalID = setInterval(function (regKey, value) {
try {
var ret;
ret = g_objRegUtil.ReadValueFromRegistry(szRegKeyVal);
if (ret == value)
// Check ret value and make decision
}
} catch (err) {
}
}, 5);
// We will wait for certain time else break the watch
setTimeout(function () {
clearInterval(intervalID);
}, g_DefaultTimeOutForRegMonitoring);
}
Comments