image thumbnail

Windows registry utilities

version 1.0.0 (7.03 KB) by Yair Altman
getRegistryValue - get a value from Windows registry (winqueryreg wrapper) setRegistryValue - set a value in the registry (new or updated)


Updated 16 Oct 2019

View License

Contains two utility functions to access the Windows registry:

1) getRegistryValue - Get a registry value. Sample usage:
value = getRegistryValue('HKEY_LOCAL_MACHINE', 'Software\Classes\.zip', 'Content Type')
value = getRegistryValue('HKEY_LOCAL_MACHINE\Software\Classes\.zip', 'Content Type')
value = getRegistryValue('HKEY_LOCAL_MACHINE\Software\Classes\.zip', '')

If the 2nd output argument (errorMsg) is requested, then registry query errors do not raise an error, but rather return an empty value and the error message. For example:
[value, errorMsg] = getRegistryValue('HKEY_CURRENT_USER', 'No-such-key', '')

2) setRegistryValue - Set a registry value. Sample usage:
[status, msg] = setRegistryValue('HKEY_CURRENT_USER', 'Software\MyProgram', 'DataFolder', 'C:\Data')
[status, msg] = setRegistryValue('HKEY_CURRENT_USER\Software\MyProgram', 'DataFolder', 'C:\Data')

Cite As

Yair Altman (2021). Windows registry utilities (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!