日期:2014-05-16 浏览次数:20336 次
<html>
<head>
<title>读网卡物理地址</title>
<script language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
document.getElementById('macaddress').value = MACAddr;
document.getElementById('ipaddress').value = IPAddr;
document.getElementById('index').value = Index;
document.getElementById('totalindex').value = TotalIndex;
</script>
<script language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
//Index:Windows网络适配器配置的索引号
//Windows网络适配器每一个配置就会触发一次OnObjectReady
//这里只取第一个TCP/IP在该适配器上为激活状态的适配器属性信息(mac地址,IP地址),eg:本地连接和无线网络都连上,只会取适配器配置中前面一个。
//TotalIndex:总配置数;Index:第一个第一个TCP/IP在该适配器上为激活状态的适配器索引号
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
{
if (Index == null || objObject.Index < Index)
{
MACAddr = objObject.MACAddress;
IPAddr = objObject.IPAddress(0);
Index = objObject.Index;
}
}
}
TotalIndex = objObject.Index;
</script>
</head>
<body>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
<SCRIPT language=JScript>
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var Index ;
var TotalIndex;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</SCRIPT>
MAC地址: <input id="macaddress"/>
IP地址: <input id="ipaddress"/>
Index: <input id="index"/>
TotalIndex: <input id = "totalindex"/>
</body>
</html>
class Win32_NetworkAdapterConfiguration : CIM_Setting
{
boolean ArpAlwaysSourceRoute;
boolean ArpUseEtherSNAP;
string Caption;
string DatabasePath;
boolean DeadGWDetectEnabled;
string DefaultIPGateway[];
uint8 DefaultTOS;
uint8 DefaultTTL;
string Description;
boolean DHCPEnabled;
datetime DHCPLeaseExpires;
datetime DHCPLeaseObtained;
string DHCPServer;
string DNSDomain;
string DNSDomainSuffixSearchOrder[];
boolean DNSEnabledForWINSResolution;
string DNSHostName;
string DNSServerSearchOrder[];
boolean DomainDNSRegistrationEnabled;
uint32 ForwardBufferMemory;
boolean FullDNSRegistrationEnabled;
uint16 GatewayCostMetric[];
uint8 IGMPLevel;
uint32 Index;
uint32 InterfaceIndex;
string IPAddress[];
uint32 IPConnectionMetric;
boolean IPEnabled;
boolean IPFilterSecurityEnabled;
boolean IPPortSecurityEnabled;
string IPSecPermitIPProtocols[];
string IPSecPermitTCPPorts[];
string IPSecPermitUDPPorts[];
string IPSubnet[];
boolean IPUseZeroBroadcast;
string IPXAddress;
boolean IPXEnabled;
uint32 IPXFrameType[];
uint32 IPXMediaType;
string IPXNetworkNumber[];
string IPXVirtualNetNumber;
uint32 KeepAliveInterval;
uint32 KeepAliveTime;
string MACAddress;
uint32 MTU;
uint32 NumForwardPackets;
boolean PMTUBHDetectEnabled;
boolean PMTUDiscoveryEnabled;
string ServiceName;
string SettingID;
uint32 TcpipNetbiosOptions;
uint32 TcpMaxConnectRetransmissions;
uint32 TcpMaxDataRetransmissions;
uint32 TcpNumConnections;
boolean TcpUseRFC1122UrgentPointer;
uint16 TcpWindowSize;
boolean WINSEnableLMHostsLookup;
string WINSHostLookupFile;
string WINSPrimaryServer;
string WINSScopeID;
string WINSSecondaryServer;
};