Recent

Author Topic: [SOLVED] Reading a registry key  (Read 1619 times)

petevick

  • Sr. Member
  • ****
  • Posts: 373
Re: Reading a registry key
« Reply #15 on: March 09, 2024, 04:06:52 pm »
Running in 32-bit this  key ('SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders') does not seem to exist, but it runs OK in 64-bit mode.

Bart
I think you were on to something Bart, on this website - https://stackoverflow.com/questions/16938305/how-to-check-if-a-registry-key-exists - it mentions....
Quote
If you actually need to do this with HKLM (as you state in a comment), watch out for registry redirection confusion when running 32 bit process on 64 bit system.
....so I believe this could well be the issue as I use a 32bit install of Laz in a 64bit Win OS, and my little project works fine in a 32 bit Win7 VM.
I'll install a 64 bit Laz to confirm.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 373
Re: Reading a registry key
« Reply #16 on: March 09, 2024, 04:26:49 pm »
....so I believe this could well be the issue as I use a 32bit install of Laz in a 64bit Win OS, and my little project works fine in a 32 bit Win7 VM.
I'll install a 64 bit Laz to confirm.
This was indeed the issue !! works just fine with a 64 bit Laz and OS.
Thanks to all who posted, particularly Bart who gave me the clue.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

Fibonacci

  • Sr. Member
  • ****
  • Posts: 439
Re: Reading a registry key
« Reply #17 on: March 09, 2024, 04:37:43 pm »
If you want to access 64 bit registry from 32 bit app simply use KEY_WOW64_64KEY access.

TRegistry.Create(KEY_WOW64_64KEY)

There is also FS redirection which can be disabled:
https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-wow64disablewow64fsredirection

petevick

  • Sr. Member
  • ****
  • Posts: 373
Re: Reading a registry key
« Reply #18 on: March 09, 2024, 05:08:43 pm »
If you want to access 64 bit registry from 32 bit app simply use KEY_WOW64_64KEY access.

TRegistry.Create(KEY_WOW64_64KEY)

There is also FS redirection which can be disabled:
https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-wow64disablewow64fsredirection
well I'll be damned, KEY_WOW64_64KEY works in both the example keys. Thank you very much Fibonacci, that will save me a fair bit of future hassle  ;D
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

 

TinyPortal © 2005-2018