O gerçekleşebilir. (Daha sonra .NET 4.0 veya gerektirir) ilk olarak bir yardımcı sınıf oluşturun:
public class RegistryHelpers
{
public static RegistryKey GetRegistryKey()
{
return GetRegistryKey(null);
}
public static RegistryKey GetRegistryKey(string keyPath)
{
RegistryKey localMachineRegistry
= RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
Environment.Is64BitOperatingSystem
? RegistryView.Registry64
: RegistryView.Registry32);
return string.IsNullOrEmpty(keyPath)
? localMachineRegistry
: localMachineRegistry.OpenSubKey(keyPath);
}
public static object GetRegistryValue(string keyPath, string keyName)
{
RegistryKey registry = GetRegistryKey(keyPath);
return registry.GetValue(keyName);
}
}
Kullanımı:
string keyPath = @"SOFTWARE\MyApp\Settings";
string keyName = "MyAppConnectionStringKey";
object connectionString = RegistryHelpers.GetRegistryValue(keyPath, keyName);
Console.WriteLine(connectionString);
Console.ReadLine();
düzgün Ana yol kaçan mı? "YAZILIM \\ TestKey" ve "YAZILIM \ TestKey" değil mi? – Michael
evet, yanlış yazdım. Bu aslında \\ – PositiveGuy
kullanmak için kurulum Yani bu benim patronun PC üzerinde çalıştı sadece iyi. Burada olmamasının bir sebebi yok. VS web sunucusunu çalıştırdığımdan ve hala null döndürdüğünden asp.net hesap erişimini verdim. – PositiveGuy