This code seems to work:
var k = Registry.LocalMachine.OpenSubKey( @"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" );
Or maybe it did not guess your code.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Using Microsoft.Win32.RegistryKey C# functions which require a registry path, like OpenSubKey(), using a path like @"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"
generates an error stating “Absolute path information is required.”
What is the syntax to create the absolute path required?
This code seems to work:
var k = Registry.LocalMachine.OpenSubKey( @"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" );
Or maybe it did not guess your code.
Hi, @Marc George I assume that keyPath
and path
are the same value. I cannot reproduce your issue, but there are some problems with your code.
rk.GetValue
, you should use the RegistryKey
object returned by OpenSubKey
. PortNumber
is of type REG_DWORD
in registry and the value you get is a Int32
, maybe you mean GetValue(keyValue).ToString();
The following sample works for me:
RegistryKey rk = Registry.LocalMachine;
string registryValue;
string keyValue = "PortNumber";
string keyPath = @"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp";
RegistryKey subkey = rk.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl);
registryValue = subkey.GetValue(keyValue).ToString();
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
From my research, key permissions that restrict access to READ operations of "ALL APPLICATION PACKAGES" will generate this error message.