有人帮助我。 为什么这段代码不能正常工作。 仍然返回null。
RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
RegistryKey rk = hklm.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IPAll",RegistryRights.ReadKey);
string valueName = "TcpPort";
答案 0 :(得分:0)
您需要替换:
hklm.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IPAll",RegistryRights.ReadKey);
与
hklm.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IPAll",RegistryRights.ReadKey);