1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = strAdmin;
oConn.Password = strPwd;
oConn.Impersonation = ImpersonationLevel.Impersonate;
oConn.Authentication = AuthenticationLevel.Default;
oConn.Authority = "ntlmdomain:mon domaine";
ManagementScope scope = new ManagementScope("\\\\" + lbPCName.Text + "\\root\\default", oConn);
ManagementClass registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null);
scope.Connect();
if (is64bit)
{
RegistryKey strKey64bit = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, "\\\\" + lbPCName.Text, RegistryView.Registry64);
strKey64bit = strKey64bit.OpenSubKey(RegRunKey64);
if (strKey64bit != null)
{
foreach (string regkey in strKey64bit.GetValueNames())
{
AddDataGridView(dataRunKey, regkey, strKey64bit.GetValue(regkey).ToString(), row);
row++;
}
} |
Partager