我要求确保在服务器中为ipv4 ip地址,子网掩码,默认网关,DNS值和WINS值输入值。
我不一定需要检查这些值以确保它们是正确的,因为正确的值是从单独的内部网站提取的。我没有办法与它接口。所以我只想确保它完全进入并且没有使用ipv6。
我似乎找不到任何可以帮助我的事情。我查看了注册表,看看我是否能找到任何可以抓取的东西。
没有运气= /
有什么建议吗?
答案 0 :(得分: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)另见Get active network interface on 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