javascript ActiveX 获取ip和MAC

<HTML><HEAD><TITLE>WMI Scripting HTML</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
 document.forms[0].txtMACAddr.value=unescape(MACAddr);
 document.forms[0].txtIPAddr.value=unescape(IPAddr);
 document.forms[0].txtDNSName.value=unescape(sDNSName);
 //document.formbar.submit();
 </SCRIPT>

<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
 if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
 {
 if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
 MACAddr = objObject.MACAddress;
 if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
 IPAddr = objObject.IPAddress(0);
 if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
 sDNSName = objObject.DNSHostName;
 }
 alert(IPAddr)
</SCRIPT>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></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 DomainAddr;
 var sDNSName;
 service.Security_.ImpersonationLevel=3;
 service.InstancesOfAsync(foo, ‘Win32_NetworkAdapterConfiguration‘);
 </SCRIPT>

<FORM id=formfoo name=formbar action=NICPost.asp method=post><INPUT value=00:05:5D:0E:C7:FA name=txtMACAddr> <INPUT value=192.168.0.2 name=txtIPAddr> <INPUT value=typ name=txtDNSName> </FORM></BODY></HTML>

<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
时间: 2024-11-03 03:39:26

javascript ActiveX 获取ip和MAC的相关文章

Android -- 获取IP和MAC地址

通过InetAddress.getLocalHost()得到始终是"127.0.0.1",要想得到真正的网络ip地址要通过下面的方法: 首先新建一个工程,修改AndroidManifest.xml文件增加用户权限,如下: <uses-permission android:name="android.permission.INTERNET"/> <!--必写--> <uses-permission android:name="a

C#获取IP及MAC地址 方法

C#获取IP及MAC地址 方法,比较齐全 using System.Net; using System; using System.Management; using System.Runtime.InteropServices; public class getIP { [DllImport("Iphlpapi.dll")] private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int

获取IP和mac地址

1.获取IP static string GetLocalIp() { string hostname = Dns.GetHostName();//得到本机名 //IPHostEntry localhost = Dns.GetHostByName(hostname);//方法已过期,只得到IPv4的地址 IPHostEntry localhost = Dns.GetHostEntry(hostname); IPAddress localaddr = localhost.AddressList[0

nova boot代码流程分析(五):VM启动从neutron-dhcp-agent获取IP与MAC

1.   network和subnet创建代码流程 [[email protected] ~(keystone_user1)]# neutron net-create demo-net [[email protected] ~(keystone_user1)]# neutron subnet-create  demo-net 1.1.1.0/24 --name demo-subnet --gateway 1.1.1.1 --enable_dhcp true 这里,我们主要分析上面两个命令的代码流

IT忍者神龟之S获取IP、MAC和主机名多方法、多平台

分享下js获取Ip地址.Mac地址与主机名的几种方法与实现代码,支持多平台下Ip地址获取,有需要的朋友参考下. 方法一(只针对IE且客户端的IE允许AcitiveX运行,通过平台:XP,SERVER03,2000): Js获取客户端IP地址. 复制代码代码示例: <HTML> <HEAD> <TITLE>GetLocalIP-js获取Ip地址-www.jbxue.com</TITLE> </HEAD> <BODY> 获取IP: <

JS获取IP、MAC和主机名的几种方法

方法一(只针对IE且客户端的IE允许AcitiveX运行,通过平台:XP,SERVER03,2000): 获取客户端IP. <HTML> <HEAD> <TITLE>GetLocalIP</TITLE> </HEAD> <BODY> 获取IP: <script language="JavaScript"> function GetLocalIPAddr(){ var oSetting = null; v

.net获取IP和MAC地址

获取IP  解决request.UserHostAddress取不到真实IP private string GetClientIP()   {    string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];    if (null == result || result == String.Empty)    {     result = HttpContext.Curren

js获取IP和MAC地址

1.IP 百度一下有很多 可以用这个 <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script type="text/javascript"> document.write(returnCitySN["cip"]+','+returnCitySN["cname"]) </script> returnC

node.js获取ip及mac

; (function (win) { var os = require('os'); var ifaces = os.networkInterfaces(); function NetworkUtil() { var _self = this; this.getMac = function(family){ var mac = ''; Object.keys(ifaces).forEach(function (ifname) { ifaces[ifname].forEach(function