I am running my application compiled as x86, and it is running on 64 bit Windows.
In order to fix a problem with ClickOnce file associations I want to read some CLSID values from the x86 view of the registry and then write them to the x64 view.
To be clear, this means that from an x86 application I want to simultaneously read from the x86 registry view and then write to the x64 registry view. I want to take the values I find under HKEY_CURRENT_USERSoftwareClassesCLSID{my clsid}
and write them to HKEY_CURRENT_USERSoftwareClassesWow6432NodeCLSID{my clsid}
.
How should I do this? Using a RegistryView
is producing unexpected results. For example, this OpenSubKey
call returns null:
keyPath = @"SoftwareClassesCLSID" + clsid;
var regularx86View = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32);
var regularClassKey = regularx86View.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadSubTree);
If I use RegistryView.RegistryDefault
or RegistryView.Registry64
instead it returns the key - but I would expect it to return null when using Registry64
because that key doesn't exist in the x64 view and there should be no redirection taking place.
Is using a RegistryView
the appropriate thing to be doing, or should I be using the WinAPI directly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…