设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3290|回复: 5
打印 上一主题 下一主题

如何获得当前机器的IP地址?

[复制链接]
跳转到指定楼层
1#
发表于 2006-8-24 03:33:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2006-8-24 04:27:00 | 只看该作者
找个WINSOCK控件用,或者WINSOCK API函数。

点击这里给我发消息

3#
发表于 2006-8-24 05:33:00 | 只看该作者
开始-运行-cmd-确定-ipconfig
4#
发表于 2006-9-7 17:29:00 | 只看该作者
1.

   Shell "cmd.exe /k ipconfig.exe", vbNormalFocus


---

2.

' 請設定引用項目Windows Script Host Object Model
Sub ipconfigAll()
Dim wscr As WshShell
Set wscr = New WshShell
    If InStr(1, Application.OperatingSystem, "NT") > 0 Then
      MsgBox wscr.Exec("ipconfig").StdOut.ReadAll   ' NT
    Else
      MsgBox wscr.Exec("winipcfg").StdOut.ReadAll   ' Win 9 - x
    End If
End Sub

---

3.

Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer

strComputer = "."
Set objWMI = GetObject("winmgmts://" & strComputer & "oot/cimv2")
Set colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
   If Not IsNull(IP.IPAddress) Then
      For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
         MsgBox IP.IPAddress(I), vbInformation, IP.Description(I)
      Next
   End If
Next
End Sub

5#
发表于 2009-8-2 07:41:46 | 只看该作者
请高手能给个实例,谢谢!
6#
发表于 2009-10-28 20:49:43 | 只看该作者
3楼正解      哈哈
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-14 14:24 , Processed in 0.094735 second(s), 29 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表