如题。谢谢!

解决方案 »

  1.   

    这些问题,前几天都有人问过。可以查看以前的帖子。1.得到本地机器的机器名Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Public Function ComputerName() As String
        Dim cn As String
        Dim ls As Long
        Dim res As Long
        
        cn = String(1024, 0)
        ls = 1024
        res = GetComputerName(cn, ls)
        
        If res <> 0 Then
            ComputerName = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
        Else
            ComputerName = ""
        End If
    End Function程序中要使用时只要直接 call 即可.例:  MsgBox "ComputerName=" & ComputerName2.得到本地机器的IP在窗体上添加一个Winsock控件
       MsgBox Winsock1.LocalIP如果不用此法,可参考
    http://expert.csdn.net/Expert/topic/2211/2211358.xml?temp=.1538813