Opensubkey () zwraca null dla klucza rejestru, który mogę zobaczyć w regedit.exe
Próbuję uzyskać wszystkie wyświetlane Nazwy klawiszy podrzędnych w tym kluczu:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Z tym kodem:
RegistryKey newKey;
string val;
string KeyPath64Bit = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey mainKey = Registry.LocalMachine.OpenSubKey(KeyPath64Bit);
string[] RegKeys64Bits = Registry.LocalMachine.OpenSubKey(KeyPath64Bit).GetSubKeyNames();
foreach (string s in RegKeys64Bits)
{
newKey = mainKey.OpenSubKey(s);
val = newKey.GetValue("DisplayName", -1, RegistryValueOptions.None).ToString();
if (val != "-1")
file64.WriteLine(val);
}
Po uruchomieniu kodu nie mogę znaleźć jednego z kluczy, których potrzebuję:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}
I powinna mieć nazwę wyświetlania: Microsoft Visual C++ 2010 x64 Redistributable - 10.0.30319, ale zamiast tego Metoda GetSubKeyNames()
daje mi klucz podrzędny: {DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}.KB2151757
, który nie ma nazwy wyświetlania.
Dlaczego nie mogę uzyskać dokładnego klucza sub ({DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}
) i jak Mogę rozumiesz?
81
Author: Zak Soliman, 2012-12-05
2 answers
32-bitowa aplikacja na 64-bitowym systemie operacyjnym będzie domyślnie patrzeć na węzeł HKLM\Software\Wow6432Node
. Aby odczytać 64-bitową wersję klucza, musisz podać RegistryView
:
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
using (var key = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
{
// key now points to the 64-bit key
}
Jeśli nadal używasz wersji 3.5, musisz użyć P/Invoke, aby uzyskać dostęp do kluczy 64-bitowych:
http://www.rhyous.com/2011/01/24/how-read-the-64-bit-registry-from-a-32-bit-application-or-vice-versa/ 188
Author: Richard Deeming,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-05 17:38:37
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-05 17:38:37
W Visual Studio 2017 przejdź do
Project > Properties > Build > Uncheck 32 bit and Platform target as "Any CPU".
16
Author: Clint,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-01-30 15:37:36
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-01-30 15:37:36