Options

Read Windows Registry from NAV2016 C/AL

rsaritzkyrsaritzky Member Posts: 469
Hi all,

I'm trying to read a registry value in NAV2016. I've defined a DotNetVariable as

ProcessFileName	 Microsoft.Win32.Registry.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

If I look in Regedit, I see a registry key I'm looking for. I exported it to a .reg file and here is the contents:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe]
@="C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe"
"Path"="C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\"


In my NAV Code, I defined a text variable "TestAcroLoc" and execute the following statement:
TestAcroLoc := FORMAT(ProcessFileName.GetValue('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe','Path','Registry Not Found'));

The return value of "TestAcroLoc" is 'null'.

I've tried an extra backslash at the end of the registry value with the same result. Also using double-backslashes instead of backslash.

Does anyone see any obvious errors?

Thanks.

Ron
Ron
Sign In or Register to comment.