0
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged"))
{
    try
    {
        foreach (string sk in rk.GetSubKeyNames())
        {
            using (RegistryKey sk1 = rk.OpenSubKey(sk))
            {    
                listBoxCard.Items.Add(sk1.GetValue("Description"));        
            }
        }
    }
    catch { }
}
4

1 回答 1

1

我已经测试了您的代码,它可以很好地列出我计算机上的网络接口。

但是,我需要提升访问信息的权限,并通过添加应用程序清单文件并在其中将requestedExecutionLevel更改为requireAdministrator来做到这一点。

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
      <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
    </requestedPrivileges>
  </security>
</trustInfo>
于 2013-08-22T07:00:00.070 回答