Another problem is driving me crazy! Below you find the code of a function which, do you guess? fails!
procedure TForm1.Stringvalue1Click(Sender: TObject);
iI, iSize, iType: Integer;
if (tvr.Selected = nil) or (tvr.Selected.Text = 'My Computer') then
pdI := nil;
response := RegOpenKeyEx(tvr.CurrentKey, PChar(tvr.ShortPath), 0, KEY_WRITE, hOpenKey);
// response := RegOpenKeyEx(HKEY_CURRENT_USER, '000\CORBA Events\', 0, KEY_WRITE, hOpenKey);
if response = ERROR_SUCCESS then
iType := REG_SZ; // Type of data that is going to be read
iSize := SizeOf(Integer); // Buffer for the value to read
if RegQueryValueEx(hOpenKey, 'String Value', nil, @iType, pcTemp, @iSize)
= ERROR_SUCCESS then
ShowMessage('KEY NOT OPEN: '+ IntToStr(response));
What happens here? In the commented line 17 you see the exact value passed with line 16. Let me explain variables used in line 16:
- tvr is TJvRegistryTreeView
- tvr.CurrentKey is a HKEY
- tvr.ShortPath is a string holding the current path without the HKEY value
Well: line 17 works, line 16 doesn't: please, I would have not only the solution but overall the explanation of waht is involving here.
As a side note, I have to admit that testing line 17 I saw that setting value doesn't work but this will be another question.
Thanks in advance to all