如何在vb中检查服务器pc或客户端pc? [英] how to check server pc or client pc in vb ?

查看:91
本文介绍了如何在vb中检查服务器pc或客户端pc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai All

如何在使用网站时检查服务器电脑或客户端电脑?在页面加载事件我需要检查服务器PC或客户端PC,如果它服务器PC我启用文本框和标签,如果不是我禁用文本框和标签,



需要检查链接中的3个条件

1.使用ip地址,如http://192.168.0.4/web/login.aspx

2.with localhost如http:/ /localhost/web/login.aspx

3.机器名称如http://admin-PC/web/login.aspx



在上述3条件下,它将以localhost为基础,代码为

 '  Dim SERVERIP As String  
Dim CLIENTIP As < span class =code-keyword>字符串 = 字符串 .Empty
' Dim ipEntry As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
' < span class =code-comment> Dim IpAddr As IPAddress()= ipEntry.AddressList
' SERVERIP = IpAddr(0)。 ToString()

CLIENTIP = Request.ServerVariables( HTTP_X_FORWARDED_FOR' 这里我得到服务器或客户端如果服务器我得到:: 1,那么我启用文本框和标签,如果客户端我将获得完整的IP地址,那么我将禁用文本框和标签。
如果 CLIENTIP = 然后
CLIENTIP = Request.ServerVariables( REMOTE_ADDR
结束 < span class =code-keyword>如果

如果(CLIENTIP = :: 1然后
txtBrowseFolder.Enabled = True
btnwatchpath.Enabled = True
其他
txtBrowseFolder.Enabled = False
btnwatchpath.Enabled = False
结束 如果





以上正确工作如果它在一个链接中使用localhost,如果它是ip地址或机器名称不起作用。



注意:请考虑客户端服务器machinsim

发布副本在服务器系统中可用,如果有人打开链接需要检查客户端或服务器pc,如果服务器pc启用控制它不能禁用控件。

请回复我尽快了





问候

Aravind

解决方案

您好b $ b

您需要在您的计算机上运行与VBScript相同的客户端代码,但是您需要列出您的计算机(客户端和服务器)并使用此vbscript获取当前计算机应用程序的名称正在破坏:



< script language =vbscript> 
<! -

函数SetComputerName
设置objNetwork = CreateObject(WScript.Network)
NAME = objNetwork.computername
Document.Forms (form1)。元素(computername)。Value = NAME
结束函数

SetComputerName()

// - >

< / script>





之后您可以根据计算机列表决定您的计算机类型,但是您可以通过检查DNS上的计算机名称来获取IP地址因此,如果你想制作一个额外的条件,它是可能的;-)



这些链接很有用:

http://www.robvanderwoude.com/vbstech_network_names_computer.php [ ^ ]

http://www.activexperts.com/activmonitor/windowsmanagement/scripts/networking/client/retrieving/ [ ^ ]



最好的问候


Hai All
How to check server pc or client pc when using web site ? in page load event i need to check server pc or client pc,if it server pc i enable textbox and label,if not i disable textbox and label,

need to check in 3 condition in a link
1.with ip address like http://192.168.0.4/web/login.aspx
2.with localhost like http://localhost/web/login.aspx
3.with machine name like http://admin-PC/web/login.aspx

in above 3 condition,it will wotk on localhost basis and code is

' Dim SERVERIP As String
 Dim CLIENTIP As String = String.Empty
 'Dim ipEntry As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
' Dim IpAddr As IPAddress() = ipEntry.AddressList
 'SERVERIP = IpAddr(0).ToString()

 CLIENTIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")'here i get server or client if it server i get ::1,then i enable textbox and label,if it client i will get full ip addres ,then i will disable textbox and label.
 If CLIENTIP = "" Then
     CLIENTIP = Request.ServerVariables("REMOTE_ADDR")
 End If

 If (CLIENTIP = "::1") Then
     txtBrowseFolder.Enabled = True
     btnwatchpath.Enabled = True
 Else
     txtBrowseFolder.Enabled = False
     btnwatchpath.Enabled = False
 End If



the above correctly work if it use localhost in an a link,if it is ip address or machine name not work.

note : pls think client server machinsim
publish copy available in server system,if anybody open link need to check whether client or server pc,if it server pc enable controls it not disable controls.
Pls reply me asap


Regards
Aravind

解决方案

Hi
You need to run client side code same as VBScript on your machine however you shoulod make a list of your computers(clients and servers) and used this vbscript for getting name of currently computer application is ruining on:

<script language="vbscript"> 
<!--

Function SetComputerName
    Set objNetwork = CreateObject("WScript.Network") 
    NAME=objNetwork.computername
    Document.Forms("form1").Elements("computername").Value = NAME
End Function

SetComputerName()

//--> 

</script> 



after that you can decide about type of your computer follow of computer list, however you can get IP Address with checking computer name on DNS thus if you want to the make a additional conditions it is possible ;-)

these links can be useful:
http://www.robvanderwoude.com/vbstech_network_names_computer.php[^]
http://www.activexperts.com/activmonitor/windowsmanagement/scripts/networking/client/retrieving/[^]

Best Regards


这篇关于如何在vb中检查服务器pc或客户端pc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆