как получить доступ к удаленному доступу к реестру между XP и Vista, используя vb.net? - PullRequest
0 голосов
/ 29 января 2010

У меня есть доступ к удаленному соединению с XP OS на Vista OS в vb.net Как это сделать?

1 Ответ

1 голос
/ 29 января 2010

Вот что вам поможет:

    'Set the machine name
    Dim MachineName = "file-server"
    'This will hold the value of the query if successful
    Dim Value As String = Nothing
    'Open the remote HKLM hive
    Dim Reg = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, MachineName)
    'Open the key
    Dim Key = Reg.OpenSubKey("Software\Microsoft\Windows\CurrentVersion")
    'OpenSubKey returns Nothing on keys that don't exist so make sure we've got something
    If Key IsNot Nothing Then
        'Grab the value
        Value = Key.GetValue("CommonFilesDir")
    Else
        'Unable to open key, do something here
    End If
    'Very important, close the key and the hive
    Key.Close()
    Reg.Close()
    Trace.WriteLine(Value)
...