我这里有一个用c#的,不知道适合你不!?
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
lblip.Text = Request.UserHostAddress;
HttpCookie objcookie = Request.Cookies["bbs"];
int ncs = 1;
if(objcookie == null)
{
objcookie = new HttpCookie("bbs");
objcookie.Values["time"] = "1";
objcookie.Expires = DateTime.Now.AddYears(50);
Response.Cookies.Add(objcookie);
}
else
{
try
{
ncs = int.Parse(objcookie.Values["time"].ToString().Trim()) + 1;
}
catch
{
ncs = 1;
}
objcookie.Values["time"] = ncs.ToString();
Response.Cookies.Add(objcookie);
} lbltimes.Text = ncs.ToString();
}
在html写:
<HTML>
<HEAD>
<title>AutoPage</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language="javascript">
function fnRecycle(){
var oDate=new Date();
var iHours=oDate.getHours();
if(iHours.length ==1){
iHours = "0" + iHours;
}
var sMinutes=oDate.getMinutes() + "";
if(sMinutes.length==1){
sMinutes="0" + sMinutes;
}
var sSeconds=oDate.getSeconds() + "";
if(sSeconds.length==1){
sSeconds="0" + sSeconds;
}
var lbldate = document.getElementById("lbldate");
lbldate.innerHTML=iHours + ":" + sMinutes + ":" + sSeconds ;
}
</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="window.setInterval('fnRecycle()',1000)">
<form id="Form1" method="post" runat="server">
<p>当前时间是:<SPAN ID="lbldate"></SPAN></p>
<p>你是第<asp:Label ID="lbltimes" Runat="server"></asp:Label>次录陆本站</p>
<p>你的IP是:<asp:Label ID="lblip" Runat="server"></asp:Label></p>
</form>
<P><FONT face="宋体"></FONT></P>
</FORM></body>
</HTML>
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
lblip.Text = Request.UserHostAddress;
HttpCookie objcookie = Request.Cookies["bbs"];
int ncs = 1;
if(objcookie == null)
{
objcookie = new HttpCookie("bbs");
objcookie.Values["time"] = "1";
objcookie.Expires = DateTime.Now.AddYears(50);
Response.Cookies.Add(objcookie);
}
else
{
try
{
ncs = int.Parse(objcookie.Values["time"].ToString().Trim()) + 1;
}
catch
{
ncs = 1;
}
objcookie.Values["time"] = ncs.ToString();
Response.Cookies.Add(objcookie);
} lbltimes.Text = ncs.ToString();
}
在html写:
<HTML>
<HEAD>
<title>AutoPage</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language="javascript">
function fnRecycle(){
var oDate=new Date();
var iHours=oDate.getHours();
if(iHours.length ==1){
iHours = "0" + iHours;
}
var sMinutes=oDate.getMinutes() + "";
if(sMinutes.length==1){
sMinutes="0" + sMinutes;
}
var sSeconds=oDate.getSeconds() + "";
if(sSeconds.length==1){
sSeconds="0" + sSeconds;
}
var lbldate = document.getElementById("lbldate");
lbldate.innerHTML=iHours + ":" + sMinutes + ":" + sSeconds ;
}
</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="window.setInterval('fnRecycle()',1000)">
<form id="Form1" method="post" runat="server">
<p>当前时间是:<SPAN ID="lbldate"></SPAN></p>
<p>你是第<asp:Label ID="lbltimes" Runat="server"></asp:Label>次录陆本站</p>
<p>你的IP是:<asp:Label ID="lblip" Runat="server"></asp:Label></p>
</form>
<P><FONT face="宋体"></FONT></P>
</FORM></body>
</HTML>
很多都可以得到本机的IP 有的可以支持解析 或者支持localhost
Dim UserLoginLog As New LoginLog
Dim LoginIp As String '登录的IP地址
Dim addressList As System.Net.IPAddress()
addressList = System.Net.Dns.GetHostByName("").AddressList
MTU=‘’
REMOTE_IPADDR=‘’
STARTMODE=‘onboot’
UNIQUE=‘
可以通过“netsh –c”或“netsh –f”命令来导入导出网络配置。如果某台远程计算机经常要在自动获得IP和手动设置IP两种网络设置间进行切换,采用配置文件法进行修改。
Step1:在远程计算机的网络参数设置为自动获得IP时,通过“netsh -c inter face dump>c:\web1.txt”命令将该设置保存为web1.txt。
Step2:在远程计算机的网络参数设置为手动配置IP时,可通过“netsh -c in terface dump>c:\web2.txt”命令将该设置保存为web2.txt。
Step3:通过psexec命令与远程计算机建立连接。
Step4:连接成功后,运行“netsh -f c:\web1.txt”即可把网络配置设置为自动获得IP的情况。而运行“netsh -f c:\web2.txt”,则可把网络配置设置为手动设置IP的情况。
Step5:当把web1.txt与web2.txt复制到其他远程计算机上时,可以通过类似于Step4中的命令,使远程计算机可在两种网络配置间进行切换。
不用程序,BAT就可以了 呵呵
# 接口配置
#========================
pushd interfacereset all
popd
# 接口配置结束#========================
# 接口配置
#========================
pushd interface ipv6uninstall
popd
# 接口配置结束# ----------------------------------
# ISATAP 配置
# ----------------------------------
pushd interface ipv6 isatappopd
# ISATAP 配置结束# ----------------------------------
# 6to4 配置
# ----------------------------------
pushd interface ipv6 6to4resetpopd
# 6to4 配置结束#=============
# 端口代理配置
#=============
pushd interface portproxyreset
popd
# 端口代理配置结束# ----------------------------------
# 接口 IP 配置
# ----------------------------------
pushd interface ip
# "本地连接" 的接口 IP 配置set address name="本地连接" source=static addr=192.168.8.131 mask=255.255.255.0
set address name="本地连接" gateway=192.168.8.1 gwmetric=0
set dns name="本地连接" source=static addr=219.150.150.150 register=PRIMARY
set wins name="本地连接" source=static addr=none
popd
# 接口 IP 配置结束
netsh -c interface dump > 1.txt
netsh -c interface dump > 2.txt
做两个按钮分别执行netsh -f 1.txt和netsh -f 2.txt
netsh -f 1.txt
netsh -f 2.txt
#========================
# 接口配置
#========================
pushd interfacereset all
popd
# 接口配置结束#========================
# 接口配置
#========================
pushd interface ipv6uninstall
popd
# 接口配置结束# ----------------------------------
# ISATAP 配置
# ----------------------------------
pushd interface ipv6 isatappopd
# ISATAP 配置结束# ----------------------------------
# 6to4 配置
# ----------------------------------
pushd interface ipv6 6to4resetpopd
# 6to4 配置结束#=============
# 端口代理配置
#=============
pushd interface portproxyreset
popd
# 端口代理配置结束# ----------------------------------
# 接口 IP 配置
# ----------------------------------
pushd interface ip
# "本地连接" 的接口 IP 配置set address name="本地连接" source=dhcp
set dns name="本地连接" source=dhcp register=PRIMARY
set wins name="本地连接" source=dhcp
popd
# 接口 IP 配置结束
就能够得到对方的IP了!
上面我说的是实现这种方法的思路
你现在只要做两个按钮,这两个按钮能执行netsh -c interface dump > 1.txt和netsh -f 1.txt的dos命令就可以了
netsh -f 1.txt
都是dos命令,-c是导出网络配置,-f是导入网络配置