如何获取本地ip地址,和机器名呢?
如何获取本地ip地址,和机器名呢?
我想将本机ip和机器名写入到数据库中,但是我不知在vfp中如何获得。
[解决办法]
*方法一:ox=Createobject("MSwinsock.Winsock")?'IP地址:',ox.LocalIP?'计算机名:',ox.LocalHostNameRelease OX*******************************************方法二:Public IPSocketcrlf=Chr(13)+Chr(10)* 显示本地 ip 地址及 计算机名IPSocket = Createobject("MSWinsock.Winsock")If Type('IPSocket')='O' IPAddress = IPSocket.LocalIP localhostname = IPSocket.LocalHostName remotehost = IPSocket.RemoteHost remotehostip = IPSocket.RemoteHostIP Messagebox ("本地 IP = " + IPAddress+crlf+"本地 host = "+LocalHostName; +crlf+"RemoteHost = "+RemoteHost+crlf+"RemoteHostIP = "+RemoteHostIP)Else Messagebox ("Winsock 未安装!")EndifRelease IPSocket*********************************************方法三:Local oWMI As Object,oLocal As Object,oHARDWARE As Object,object1 As Object,lcCPUID,LcMAC,lcHDID,lcSerialoWMI=Createobject("WbemScripting.SWbemLocator")oLocal=oWMI.ConnectServer(".", "root\cimv2")oHARDWARE=oLocal.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=1")For Each object1 In oHARDWARE LcIP=object1.Properties_('IPAddress').Value ExitEndfor?'IP地址:',LcIP*********************************************方法四: 太麻烦不帖了。
[解决办法]
机器名就更简单了:
? Left(ID(), At('#',ID()) - 1)