Daemon and Registry lazarus / 34-Windows ---------------------------------------------------------------------- bambamns · 2014-09-24 17:56 Hi, I wrote a daemon (service) and one of options is to access to registry. Code is in execute part of thread : Code: [Select]reg := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY);   try    reg.RootKey := HKEY_CURRENT_USER;    if reg.OpenKeyReadOnly('\Software\Firebird Backup') then      Dir := reg.ReadString('path');   finally    reg.Free;   end;                                    But it wont read a key like it not exist (but it does). If I copy this code to win32 application it works. Any clue ? ---------------------------------------------------------------------- BigChimp · 2014-09-25 06:18 No experience with services but... My guess is the service doesn't run under the correct user/doesn't have the right permissions/can't even access the CURRENT_USER part of the registry. IIRC there have been similar posts on the forum before... ---------------------------------------------------------------------- bambamns · 2014-09-25 20:06 This was my guessing, but the service is installed and started from command line with admin credentials and that was the reason to use OpenKeyReadOnly. But solution is just to change the rootkey to HKLM , write the values under HKLM you wont yo use and everything works. I hope it will help someone. ---------------------------------------------------------------------- ChrisF · 2014-09-25 21:14 AFAIK, HKCU for a service points to HKEY_USER\.Default. That's probably the reason of your trouble with the first version of your code.