Office中国论坛/Access中国论坛

标题: 如何获得当前机器的IP地址? [打印本页]

作者: 若风1    时间: 2006-8-24 03:33
标题: 如何获得当前机器的IP地址?
1
作者: 老鬼    时间: 2006-8-24 04:27
找个WINSOCK控件用,或者WINSOCK API函数。
作者: pureshadow    时间: 2006-8-24 05:33
开始-运行-cmd-确定-ipconfig
作者: Lotustower    时间: 2006-9-7 17:29
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


作者: herry2003aa    时间: 2009-8-2 07:41
请高手能给个实例,谢谢!
作者: lkahd_0817    时间: 2009-10-28 20:49
3楼正解      哈哈




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3