Private Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
Public Function GetThisComputerName(ByRef ComputerName As String) As Boolean
' Returns Computer name
Dim lpBuffer As String
Dim i As Long
Const BUFMAXLENGTH = 256
ComputerName = ""
GetThisComputerName = False
lpBuffer = Space$(BUFMAXLENGTH)
i = BUFMAXLENGTH
i = GetComputerName(lpBuffer, i)
If i > 0 Then
i = InStr(lpBuffer, Chr(0))
ComputerName = Left$(lpBuffer, i - 1)
GetThisComputerName = True
I need a programme or procedure which is capable in generating IP or computer name of the system( on which programme is running).
Has this been resolved or are you still looking? I have a very quick and easy 3 line tiny piece of code i used ages ago that will give you exactly what you need (PC name)... Then you can edit it to your hearts content to give you usernames etc as well...
if you still require it let me know and ill pop it in here for ya... :-)
I've just re-read that... do you mean you want a program to create a PC name on the PC in which the app is ran ... or to greturn the pc name of the pc your running the app on?
Your post can be read both ways... :-)
My little line of code will give you the name of a pc you run it on, and/or the username of the users logged in etc... i found it very hand when i uneeded it a few years ago for back up purposes.