Click to See Complete Forum and Search --> : How Do find machine name using API's...
sarmasomu
May 17th, 1999, 11:49 AM
HI ,
How do we find out the local machine name and remote machine name using API's in VB .
I need sample code for calling API's.
Using Controls,how do find out the machine name(Local/Remote).
Thanks,
Sarma Somu
Crazy D
May 17th, 1999, 01:13 PM
Hi
For the local computername, copy this to a basfile:
option Explicit
private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (byval lpBuffer as string, nSize as Long) as Long
private Const MAX_COMPUTERNAME_LENGTH = 16 ' 15, but always + 1 for the null terminator
public Function ComputerName() as string
Dim sName as string * MAX_COMPUTERNAME_LENGTH
Dim nSize as Long
nSize = len(sName)
If GetComputerName(sName, nSize) <> 0 then
' nSize contains on return the no of chars exluding the null char...
' so get the left of sName
ComputerName = Left(sName, nSize)
else
ComputerName = ""
End If
End Function
Crazy D :-)
Lothar Haensler
May 18th, 1999, 03:14 AM
Crazy D told you how to get the local computer name. To get the name of the domain controller, call the NetGetDCName API.
sarmasomu
May 18th, 1999, 09:44 AM
I got the local system name using the Crazy D code. I need Remote Host( remotesystem ) name .
To fnd a remote host name ,what type of requirments we need lke IP address , PORT name.
So i need the code for finding the remote host name.
I didn't catch the "call the NetGetDCName" point...can you explain briefly..
Thanks,
Sarma Somu
Lothar Haensler
May 18th, 1999, 09:47 AM
honestly, I think I misunderstood your question.
NetGetDCName would give you the name of the primary domain controller in an NT network. Obviously, that's not what you need.
Sorry for the confusion.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.