registry - valueexists
-
Hi Helpers, I am having a little trouble with the Tregistry object. In the Code below theReg.ValueExists function is returning false even though my value is there. Does ValueExists only work on non string values? If so, how can I check that my value does exist in the key? Help Greatly Appreciated. theReg.RootKey := HKEY_LOCAL_MACHINE; KeyName := '\Software\MyGroup\Safe'; if (theReg.KeyExists(KeyName)) then begin BackUpDir := ''; if theReg.ValueExists('BackUpDir') then begin theReg.OpenKey(KeyName, False); BackUpDir := theReg.ReadString('BackUpDir'); end; :suss: Sean
-
Hi Helpers, I am having a little trouble with the Tregistry object. In the Code below theReg.ValueExists function is returning false even though my value is there. Does ValueExists only work on non string values? If so, how can I check that my value does exist in the key? Help Greatly Appreciated. theReg.RootKey := HKEY_LOCAL_MACHINE; KeyName := '\Software\MyGroup\Safe'; if (theReg.KeyExists(KeyName)) then begin BackUpDir := ''; if theReg.ValueExists('BackUpDir') then begin theReg.OpenKey(KeyName, False); BackUpDir := theReg.ReadString('BackUpDir'); end; :suss: Sean
TRegistry? Let me guess you are using Borland? First thing you need to do is get a real development tool like VC++. If you read the documentation you will find that RegOpenKeyEx will return none zero if the key does not exist. HKEY hKey; if( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, "\Software\MyGroup\Safe", KEY_READ, NULL, &hKey) ) { // Key exists } else { // Key does not exist }