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
Printable View
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
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 :-)
Crazy D told you how to get the local computer name. To get the name of the domain controller, call the NetGetDCName API.
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
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.