0

我需要确保在服务器中输入 ipv4 ip 地址、子网掩码、默认网关、DNS 值和 WINS 值的值。

我不一定需要检查这些值以确保它们是正确的,因为正确的值是从单独的内部网站中提取的。我没有办法与之交互。所以我只想确保它完全输入并且没有使用ipv6。

我似乎找不到任何可以帮助我的东西。我查看了注册表,看看是否可以找到任何可以抓取的东西。

没有运气=/

有什么建议么?

4

1 回答 1

1

你的问题不清楚。这几乎听起来像是您想从输入字段中读取一个值,但随后您说出了有关注册表的内容。您需要更清楚地询问您在哪里寻找所述信息。

考虑到这一点,假设您的意思是要确定系统是否已获取 IP 地址等,然后考虑以下内容。

1)您可以使用 Run 方法并执行ipconfig /all和解析其结果。

2)您可以使用netsh.exe并解析结果。例如:

C:\> netsh interface ipv6 show address
IPv6 is not installed.

通过这种方法可以获得很多信息。

3)您可以查看注册表。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards通常包含一个数字子键列表。例如,在我的系统上,有HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\9. 此键包含值:

Description REG_SZ "Broadcom NetXtreme 57xx Gigabit Controller"
ServiceName REG_SZ "{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B}"

当然,ServiceName GUID 会有所不同。它对每个系统都是唯一的,但对于以下内容,我将在示例中使用它。你必须用你的系统来替换它。

这指向HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B}\Parameters\Tcpip以下值的存储位置:

"EnableDHCP"=dword:00000001
"IPAddress"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"SubnetMask"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"DefaultGateway"=hex(7):00,00
"DhcpIPAddress"="10.152.30.49"
"DhcpSubnetMask"="255.255.255.0"
"DhcpServer"="10.152.28.23"
"Lease"=dword:0003f480
"LeaseObtainedTime"=dword:503f5dd6
"T1"=dword:50415816
"T2"=dword:5042d3c6
"LeaseTerminatesTime"=dword:50435256
"DhcpDefaultGateway"=hex(7):31,00,30,00,2e,00,31,00,35,00,32,00,2e,00,33,00,30,\
  00,2e,00,31,00,00,00,00,00
"DhcpSubnetMaskOpt"=hex(7):32,00,35,00,35,00,2e,00,32,00,35,00,35,00,2e,00,32,\
  00,35,00,35,00,2e,00,30,00,00,00,00,00

它还指向HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B}以下值的存储位置:

"UseZeroBroadcast"=dword:00000000
"EnableDeadGWDetect"=dword:00000001
"EnableDHCP"=dword:00000001
"IPAddress"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"SubnetMask"=hex(7):30,00,2e,00,30,00,2e,00,30,00,2e,00,30,00,00,00,00,00
"DefaultGateway"=hex(7):00,00
"DefaultGatewayMetric"=hex(7):00,00
"NameServer"=""
"Domain"=""
"RegistrationEnabled"=dword:00000001
"RegisterAdapterName"=dword:00000000
"TCPAllowedPorts"=hex(7):30,00,00,00,00,00
"UDPAllowedPorts"=hex(7):30,00,00,00,00,00
"RawIPAllowedProtocols"=hex(7):30,00,00,00,00,00
"NTEContextList"=hex(7):30,00,78,00,30,00,30,00,30,00,30,00,30,00,30,00,30,00,\
  32,00,00,00,00,00
"DhcpClassIdBin"=hex:
"DhcpServer"="10.152.28.23"
"Lease"=dword:0003f480
"LeaseObtainedTime"=dword:503f5dd6
"T1"=dword:50415816
"T2"=dword:5042d3c6
"LeaseTerminatesTime"=dword:50435256
"IPAutoconfigurationAddress"="0.0.0.0"
"IPAutoconfigurationMask"="255.255.0.0"
"IPAutoconfigurationSeed"=dword:00000000
"AddressType"=dword:00000000
"IsServerNapAware"=dword:00000000
"DhcpIPAddress"="10.152.30.49"
"DhcpSubnetMask"="255.255.255.0"
"DhcpRetryTime"=dword:0001fa40
"DhcpRetryStatus"=dword:00000000
"DhcpNameServer"="10.125.28.23 10.125.28.21 192.168.115.2"
"DhcpDefaultGateway"=hex(7):31,00,30,00,2e,00,31,00,35,00,32,00,2e,00,33,00,30,\
  00,2e,00,31,00,00,00,00,00
"DhcpDomain"="my.domain.Local"
"DhcpSubnetMaskOpt"=hex(7):32,00,35,00,35,00,2e,00,32,00,35,00,35,00,2e,00,32,\
  00,35,00,35,00,2e,00,30,00,00,00,00,00

这应该让你开始。据推测,您可以在注册表中搜索{A1167D26-ADE0-4CDB-B0C6-1F8C5CF9DF5B}与您的网络适配器相关的其他有趣信息。例如:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Dhcp\Parameters\...
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\LanmanServer\Linkage\...
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\lanmanworkstation\Linkage\...
... and so on ...

这些位置中的每一个都具有丰富的交叉引用和有关网络子系统的数据。

4) 另请参阅在 Windows 上获取活动网络接口。特别是,看看开头的答案:

You don't need make a new API. Use the WMI class from VBScript.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx

5) 有用的 WMIC 命令链接在这里:WMIC-Snippets > NIC properties

于 2012-08-30T14:50:09.913 回答