valueExists
Category: Registry Operations
Namespace: web.registry.valueExists
Description
Checks whether a specific value exists within a registry key under HKEY_CURRENT_USER.
Syntax
const exists = await web.registry.valueExists({
keyPath: 'Software\\MyApp',
valueName: 'Setting'
});
Parameters
- keyPath (required) - Registry key path under HKEY_CURRENT_USER
- valueName (required) - Name of the registry value to check
- rootKey (optional) - Currently ignored; always uses HKEY_CURRENT_USER
Returns
Promise<boolean> - Returns a promise that resolves with true if the value exists, false otherwise
Examples
Simple example
const exists = await web.registry.valueExists({
keyPath: 'Software\\MyApp',
valueName: 'Username'
});
if (exists) {
console.log('Username is saved');
} else {
console.log('No username saved');
}
Conditional reading
const valueName = 'LastOpenedFile';
const exists = await web.registry.valueExists({
keyPath: 'Software\\MyApp',
valueName: valueName
});
if (exists) {
const filePath = await web.registry.readValue({
keyPath: 'Software\\MyApp',
valueName: valueName
});
console.log('Last file:', filePath);
} else {
console.log('No previous file');
}
Check multiple settings
const settings = ['Theme', 'Language', 'FontSize'];
const keyPath = 'Software\\MyApp\\Settings';
for (const setting of settings) {
const exists = await web.registry.valueExists({
keyPath: keyPath,
valueName: setting
});
console.log(`${setting}: ${exists ? 'saved' : 'not set'}`);
}
Use Cases
- Check if a specific setting has been saved
- Verify value exists before reading
- Distinguish between empty string and non-existent value
- Validate registry structure
- Check for optional configuration values
Notes
- Always operates under
HKEY_CURRENT_USERroot key - Returns
falseif the key doesn't exist - Returns
falseif the value doesn't exist - More precise than checking if
readValue()returns empty string - Use
keyExists()to check if the entire key exists