ComputerNames and DNS name

Does anybody know how I can find out the local Comp.Name
and DNS name under VB4 ????
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

'get the user name of the computer
'put this in your bas module
Public Declare Function GetComputerName Lib _
"kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Public Function sGetComputerName() As String
  Dim sBuffer As String
  Dim lBufSize As Long
  Dim lStatus As Long
  lBufSize = 255
  sBuffer = String$(lBufSize, " ")
  lStatus = GetComputerName(sBuffer, lBufSize)
  sGetComputerName = ""
  If lStatus <> 0 Then
     sGetComputerName = Left(sBuffer, lBufSize)
  End If
  Form1.Label2 = sGetComputerName
End Function

'put this in the click event (load...whatever)
      Dim x
      x = sGetComputerName
'get the Window's username of system
'Make a new project. Add a module.
'To the form add a label.

'Add this code to the module:

Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long

'this is form load

Dim s As String
Dim cnt As Long
Dim dl As Long
Dim CurUser As String
cnt = 199
s = String$(200, 0)
dl = GetUserName(s, cnt)
If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = ""
msgbox  CurUser

Getting the I.P for a Given URL/Computer/Server Name..

Add a Command Button and 2 Textboxes to a Form..

Private Const MAX_WSADescription = 256
Private Const MAX_WSASYSStatus = 128
Private Const WS_VERSION_REQD = &H101
Private Type HOSTENT
   hName As Long
   hAliases As Long
   hAddrType As Integer
   hLen As Integer
   hAddrList As Long
End Type
Private Type WSADATA
   wVersion As Integer
   wHighVersion As Integer
   szDescription(0 To MAX_WSADescription) As Byte
   szSystemStatus(0 To MAX_WSASYSStatus) As Byte
   wMaxSockets As Integer
   wMaxUDPDG As Integer
   dwVendorInfo As Long
End Type
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal szHost As String) As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Function GetIPAddress(ByVal sHost As String) As String
    Dim I As Integer
    Dim lHost As Long
    Dim lIP As Long
    Dim sIP() As Byte
    Dim sFullIP As String
    Dim tHost As HOSTENT
    Dim tSocket As WSADATA
    'Establish an Open Socket
    If WSAStartup(WS_VERSION_REQD, tSocket) <> 0 Then Exit Function
    'Attempt to Locate Data pointer for Specified Host Name
    lHost = gethostbyname(sHost)
    If lHost = 0 Then
        MsgBox "Unable to Locate Host."
        'Get the Host Info
        CopyMemory tHost, lHost, Len(tHost)
        'Extract the Address of the IP Data from the Addresslist Pointer
        CopyMemory lIP, tHost.hAddrList, Len(tHost.hAddrList)
        'Build a Tempory array to hold the IP Values
        ReDim sIP(tHost.hLen - 1)
        'Copy the IP Values into the Array
        CopyMemory sIP(0), lIP, tHost.hLen
        'Build the IP Address
        For I = 0 To tHost.hLen - 1
            sFullIP = sFullIP & "." & sIP(I)
        'Trim of the Preceeding Period
        GetIPAddress = Mid(sFullIP, 2)
    End If
    'Close up the Socket
    Call WSACleanup
End Function
Private Sub Command1_Click()
    Text2 = GetIPAddress(Text1)
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

MatthiasKAuthor Commented:
Great, that helps. Is there a way for the Domain Name as
well ???
MatthiasKAuthor Commented:
I'm looking more for local name resolution eg DNS and
Someone answered to the similiar question.. 

If this is not what you are looking for, please let me know and I will work on it.
MatthiasKAuthor Commented:
The other answer is for DSN's I believe thats not
for the local Domain Name.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.