1

This stupid problem is driving me crazy: I'm trying to retrieve Notepad++ installation directory fro the registry by reading the default value of HKLM\SOFTWARE\Notepad++ (which is C:\Program Files\Notepad++).

I tried different methods, which all work on other keys, but not with Notepad++. All of the following methods work with all keys I tried but Notepad++:

// Using RegQueryStringValue
var
  Mess: String;
...
If RegQueryStringValue(HKLM, 'SOFTWARE\Google\Chrome\NativeMessagingHosts\com.avast.nativeproxy', '', Mess) Then
  MsgBox('Retrieved: '+Mess, mbInformation, MB_OK)
Else
  MsgBox('Wala', mbError, MB_OK);
// Using registry constants
MsgBox('Your NPP: '+ExpandConstant('{reg:HKLM\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.avast.nativeproxy,}), mbInformation, MB_OK);

Whenever I replace SOFTWARE\Google\Chrome\NativeMessagingHosts\com.avast.nativeproxy with SOFTWARE\Notepad++, I get an empty string (or RegQueryStringValue() returns false).

I thought the ++ could cause problems so I also tried to double them, escape them with 'Notepad'+#43+#43 or 'Notepad%43%43' but nothing is working.

Did I miss something obvious?

Matthieu
  • 2,736
  • 4
  • 57
  • 87
  • 1
    See [@Epu's answer to Inno Setup doesn't allow access to all registry keys, why?](https://stackoverflow.com/q/4033976/850848#6333463) – Martin Prikryl Oct 11 '19 at 16:51
  • @MartinPrikryl, I voted to close my own question as a duplicate of the one you indicated, as it was indeed the same problem: using ` HKML64` instead of `HKLM` solved it. Thanks again! – Matthieu Oct 13 '19 at 19:37
  • 1
    Though make sure you use `HKLM64` on 64-bit machines only. On 32-bit machines, use `HKLM32`. – Martin Prikryl Oct 14 '19 at 05:30

0 Answers0