D
D
DeeUs2021-07-15 08:21:07
Delphi
DeeUs, 2021-07-15 08:21:07

Why can't get data from the registry?

Hello! Faced a problem - unable to get a specific value from the registry

the code

Reg:=TRegistry.Create;
  Reg.RootKey := HKEY_CURRENT_USER;
  Reg.OpenKey('\SOFTWARE\myapp' , true);
  if Reg.ValueExists('cur_ver') then cur_ver := Reg.ReadString('cur_ver');
// cur_ver остается пустым, хотя я только что её создал в помощью другой программы.
// если написать вот так Reg.ReadString('u_name'); то я получаю значение


Along with this variable there is a variable u_name - I successfully get it
Both variables are written by another program, both variables are a string
Why can I get one variable but not the second?
I have also tried running the program as administrator.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2021-07-15
@kalapanga

Miracles don't happen. Check the code for elementary typos. Maybe they renamed something somewhere. (Here in the question you have u_name, and in the picture UserName - maybe with the version as well) Your line reading from the register may either not find a value or consider it empty - check which option is yours. Maybe the program that writes to the registry has stopped writing. Etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question