PDA

View Full Version : Registry DoesValueExist


Magellan
08-11-2006, 07:32 PM
Hi. I've been searching for about a day to find how i could tell my program to look for a specific Value in the registry and do an action when it finds it.

But i have a problem. the function DoesKeyExist is working well with keys, but i don't know what to do for values. I don't want to look for a value's value, but only the name of the value.

I thought i could then use GetValueNames, but i'd like to know how to search for one specific value in the table it returns.

Thank you.

Magellan
08-11-2006, 08:19 PM
Ok... i've worked that out, but i suggest a new registry option that would allow such search.

Here's what i did:

names = Registry.GetValueNames(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run");

names_str = Table.Concat(names, "-", 1, TABLE_ALL);

result = String.Find(names_str, "Ange", 1, true);

if result >= 0 then

Dialog.Message("Notice", "oui", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

else

Dialog.Message("Notice", "non", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

end

Could i have it done it differently ? :huh

mwreyf1
08-14-2006, 01:47 PM
Try this...


Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "Specific Value", true);
if Application.GetLastError() == 0 then
Dialog.Message("Notice", "Registry value 'Specific Value' does exist", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
Dialog.Message("Notice", "Registry value 'Specific Value' does NOT exist", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end