Recent

Author Topic: Obtaining Driver parameter for TODBCConnection  (Read 1437 times)

rvk

  • Hero Member
  • *****
  • Posts: 5648
Re: Obtaining Driver parameter for TODBCConnection
« Reply #15 on: July 20, 2023, 01:20:52 pm »
Hmm..... i think i see where the confusion comes from.
KEY_WOW64_32KEY defines the Access-Rights i request when accessing the Registry.
If i'm lazy i could just request KEY_ACCESS_ALL (or whatever it's called)
No, KEY_WOW64_xxKEY and KEY_ACCESS_ALL are two different things.

If you have a 32 bit application and you want total access to the entire registry tree (including the 64 bit ones in SOFTWARE) then you pass KEY_WOW64_64KEY. In that case you have the 32 bit registry in the WOW6432Node. But you passed KEY_WOW64_32KEY for 32 bit app in your example. Then you only have access to the 32 bit and you don't get a WOW6432Node node (konikula confirmed that).

But... directly accessing WOW6432Node (via KEY_WOW64_64KEY) isn't advised supported (see that article from Microsoft).
So you should pass KEY_WOW64_32KEY if your searching for 32 bit but then you don't have the WOW6432Node because you are already in that.

BTW. In my program I do KEY_WOW64_64KEY and access both Software and Software/WOW6432Node because then you can do it in one go. If you want to check for 32 AND 64 bit then you would officially need to close and reopen the registry (which with KEY_WOW64_64KEY isn't nessecary because you have that 'forbidden' WOW6432Node).


I may suffice without ifdef, and without further recognising version of OS. Am I right?
Yes.

If you only target 32 bit ODBC because you have a 32 bit application, you don't even need to do anything special. Your 32 bit application will only search for 32 bit ODBC in Software (which is Software/WOW6432Node on 64 bit OS and Software on a 32 bit OS). You only need the special KEY_WOW if you want to detect another bitness of the ODBC (which you don't need to).
« Last Edit: July 20, 2023, 01:25:17 pm by rvk »

Zvoni

  • Hero Member
  • *****
  • Posts: 2032
Re: Obtaining Driver parameter for TODBCConnection
« Reply #16 on: July 20, 2023, 03:15:57 pm »
Hmm..... i think i see where the confusion comes from.
KEY_WOW64_32KEY defines the Access-Rights i request when accessing the Registry.
If i'm lazy i could just request KEY_ACCESS_ALL (or whatever it's called)
No, KEY_WOW64_xxKEY and KEY_ACCESS_ALL are two different things.

If you have a 32 bit application and you want total access to the entire registry tree (including the 64 bit ones in SOFTWARE) then you pass KEY_WOW64_64KEY. In that case you have the 32 bit registry in the WOW6432Node. But you passed KEY_WOW64_32KEY for 32 bit app in your example. Then you only have access to the 32 bit and you don't get a WOW6432Node node (konikula confirmed that).

But... directly accessing WOW6432Node (via KEY_WOW64_64KEY) isn't advised supported (see that article from Microsoft).
So you should pass KEY_WOW64_32KEY if your searching for 32 bit but then you don't have the WOW6432Node because you are already in that.

BTW. In my program I do KEY_WOW64_64KEY and access both Software and Software/WOW6432Node because then you can do it in one go. If you want to check for 32 AND 64 bit then you would officially need to close and reopen the registry (which with KEY_WOW64_64KEY isn't nessecary because you have that 'forbidden' WOW6432Node).
Ah...OK, finally got you.
Yeah, but in that case couldn't/shouldn't the Variable "ODBCKey" be set outside the conditional, since it stays the "same"?
in the Conditional you'd just need to choose which KEY_WOW64_XXKEY value you have to use
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

rvk

  • Hero Member
  • *****
  • Posts: 5648
Re: Obtaining Driver parameter for TODBCConnection
« Reply #17 on: July 20, 2023, 03:28:36 pm »
Ah...OK, finally got you.
Yeah, but in that case couldn't/shouldn't the Variable "ODBCKey" be set outside the conditional, since it stays the "same"?
in the Conditional you'd just need to choose which KEY_WOW64_XXKEY value you have to use
It can. Otherwise you have two same lines.

But for 32 bit application you wouldn't even need to pass KEY_WOW64_32KEY because that's default for a 32 bit application.

If you have a 64 bit application and you want to see it 32 bit ODBC is installed, then you would need KEY_WOW64_32KEY so you don't need to use the WOW6432Node.

So:
32 bit application is KEY_WOW64_32KEY default and only sees the WOW6432Node (but without the actual WOW6432Node).
64 bit application is KEY_WOW64_64KEY default and sees it's own Software AND the WOW6432Node (but it shouldn't access WOW6432Node according to MS).

You only need KEY_WOW64_32KEY on 64 bit app to access to 32 bit registry WOW6432Node via \Software.
You only need KEY_WOW64_64KEY on 32 bit app to access to 64 bit registry via \Software.

You don't need any key to access 32 bit app -> 32 bit registry or 64 bit app -> 64 bit registry.

Regsitry-fun  :D
Quote
By default, a 32-bit application running on WOW64 accesses the 32-bit registry view and a 64-bit application accesses the 64-bit registry view. The following flags enable 32-bit applications to access redirected keys in the 64-bit registry view and 64-bit applications to access redirected keys in the 32-bit registry view. These flags have no effect on shared registry keys. For more information, see Registry Keys Affected by WOW64.
https://learn.microsoft.com/en-us/windows/win32/winprog64/accessing-an-alternate-registry-view

 

TinyPortal © 2005-2018