DeleteSettingfor reading and writing the Windows Registry. (For detailed info see the Microsoft VBA help for these functions or look at the MSDN)
But unfortunately you can't access the entire registry, only the path
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\. So you can create, save and read user settings for your own Visual Basic application, but you can't access settings for any other application (e.g. the Default download directory for the Internet Explorer, which, btw, is
ernet Explorer\Download Directory
Fortunately, when programming with VBA, you're not limited to what functionality VBA offers. By making use of Windows Scripting features, you can access the entire Window Registry quite easily.
Reading from the Registry:
Checking if a Registry key exists:
Saving a Registry key:
Deleting a key from the Registry:
These functions need the Registry key with its complete path, so
i_RegKeymust always begin with one of the following values:
RegKeySave also has an input parameter for the type of the Registry key value. Supported are the following types:
REG_SZ- A string. If the type is not specified, this will be used as Default.
REG_DWORD- A 32-bit number.
REG_EXPAND_SZ- A string that contains unexpanded references to environment variables.
REG_BINARY- Binary data in any form. You really shouldn't touch such entries.
Finally, here's a little program for testing the above functions:
Of course, the usual warnings apply:
Don't mess around with the Registry if you don't know what you're doing, or it could have severe consequences! If you change entries you're not too sure about, backup the registry first! Don't delete entries, better rename them, so you can easily get them back if your change didn't what you wanted! Only delete them when you're absolutely sure you (and neither Windows nor any application) don't need them anymore! You change the Registry at your own risk!