Ho scoperto che potrei come CraigTP ha mostrato utilizzare il metodo OpenRemoteBaseKey() tuttavia mi ha richiesto di modificare le autorizzazioni nel Registro di sistema sui computer di destinazione.
Ecco il codice che ho scritto che lavoravo una volta ho cambiato i permessi.
RegistryKey rkey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "RemoteComputer");
RegistryKey rkeySoftware = rkey.OpenSubKey("Software");
RegistryKey rkeyVendor = rkeySoftware.OpenSubKey("VendorName");
RegistryKey rkeyVersions = rkeyVendor.OpenSubKey("Versions");
String[] ValueNames = rkeyVersions.GetValueNames();
foreach (string name in ValueNames)
{
MessageBox.Show(name + ": " + rkeyVersions.GetValue(name).ToString());
}
Ho anche trovato che potrei ottenere le stesse informazioni usando WMI senza dover modificare i permessi. Ecco il codice con WMI.
ManagementScope ms = new ManagementScope();
ms.Path.Server = "flebbe";
ms.Path.NamespacePath = "root\\default";
ms.Options.EnablePrivileges = true;
ms.Connect();
ManagementClass mc = new ManagementClass("stdRegProv");
mc.Scope = ms;
ManagementBaseObject mbo;
mbo = mc.GetMethodParameters("EnumValues");
mbo.SetPropertyValue("sSubKeyName", "SOFTWARE\\VendorName\\Versions");
string[] subkeys = (string[])mc.InvokeMethod("EnumValues", mbo, null).Properties["sNames"].Value;
ManagementBaseObject mboS;
string keyValue;
foreach (string strKey in subkeys)
{
mboS = mc.GetMethodParameters("GetStringValue");
mboS.SetPropertyValue("sSubKeyName", "SOFTWARE\\VendorName\\Versions");
mboS.SetPropertyValue("sValueName", strKey);
keyValue = mc.InvokeMethod("GetStringValue", mboS, null).Properties["sValue"].Value.ToString();
MessageBox.Show(strKey + " : " + keyValue);
}
P.S. Sto chiamando il metodo GetStringValue() nel ciclo come so che tutti i valori sono stringhe. Se sono disponibili più tipi di dati, è necessario leggere il tipo di dati dal parametro di output Tipi del metodo EnumValues.
Hai considerato WMI? –