Say I would like to store a string in a folder in the registry such as the software folder, is it safe to do so? Is there a change the registry may become corrupted without interfering with windows files etc?
Are there any unique identification numbers which can be read from the registry using the RegRead?
RegWrite - Safety issues
Re: RegWrite - Safety issues
Yes and yes.labrint wrote: ↑24 Jun 2019, 05:03Say I would like to store a string in a folder in the registry such as the software folder, is it safe to do so? Is there a change the registry may become corrupted without interfering with windows files etc?
Are there any unique identification numbers which can be read from the registry using the RegRead?
You can store your own string values in the registry easily. Many people use this method to store passwords so their code only references the password value instead of showing the password in the code itself. I would recommend creating a key as an identifier in HKEY_CURRENT_USER (HKCU) then further entries. For example:
HKCU\Software\MYkey\MyGUID (to store unique identification numbers)
HKCU\Software\MYkey\MyString1 (to store your string)
HKCU\Software\MYkey\MyToggle (to store 0 or 1)
With regard to safety, it's perfectly safe. I prefer using the HKEY_CURRENT_USER hive instead of HKEY_LOCAL_MACHINE for the simple reason that only I have easy access to it when logged in using my account.
You can create your own unique identification numbers (called GUIDs) using AHK then read and write them to/from the registry. For example, the following code will generate a GUID for you:
Code: Select all
clipboard := "" ; This clears the clipboard
TypeLib := ComObjCreate("Scriptlet.TypeLib")
NewGUID := TypeLib.Guid ; This creates the GUID
clipboard = %NewGUID% ; This copies the GUID to the windows clipboard
MsgBox %NewGUID% ; This displays the GUID
Re: RegWrite - Safety issues
Thanks,
I went a bit further down HKEY_CURRENT_USER\Software\Classes\MyFolder
Still safe? Wanted to disguse it, as it being used to authenticate the use of my script.
I went a bit further down HKEY_CURRENT_USER\Software\Classes\MyFolder
Still safe? Wanted to disguse it, as it being used to authenticate the use of my script.
Re: RegWrite - Safety issues
Yes, it's still safe... although if you want to disguise data from being human-readable, i.e. to obscure from casual observation, then consider the use of simple encryption in your code and read/writing the encrypted data to/from the registry.
I'm sure I've seen example code here in the 'Scripts and Functions' forum (search for 'encryption' or 'obfuscation') but didn't follow it up as I personally don't have any need (as yet).
Hope this helps...
Re: RegWrite - Safety issues
Thanks RickC, I already use them and you are right, they are useful.
Who is online
Users browsing this forum: zerox and 144 guests