|
-
Feb 12th, 2001, 09:56 PM
#1
Thread Starter
New Member
Hi Guys,
How can I get the name of the logged in computer?
I tried the GetComputerName API but it is not returning anything.. Pl. Help.
Thank You
-
Feb 12th, 2001, 10:16 PM
#2
Lively Member
I got this from API guide...
Code:
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim strString As String
'Create a buffer
strString = String(255, Chr$(0))
'Get the computer name
GetComputerName strString, 255
'remove the unnecessary chr$(0)'s
strString = Left$(strString, InStr(1, strString, Chr$(0)))
'Show the computer name
MsgBox strString
End Sub
If this doesn't help, post what you tried here and I will see what I can do.
-
Feb 13th, 2001, 08:25 AM
#3
Fanatic Member
If you are looking for the name of the computer you are using, you can use the API posted above or use the Environ function.
Code:
MsgBox Environ ("COMPUTERNAME")
-
Feb 13th, 2001, 11:42 AM
#4
Addicted Member
private declare function GetComputerName _
Lib Kernel32" Alias "GetComputerNameA" _
(Byval lpBuffer As String,Byval nSize As Long) _
As Long
public function sGetCmpName()
Dim computer as String
Dim bufsize AS Long
Dim RetCode As Long
Dim NullCharPos As Long
Computer=Space(80)
BufSize=Len(Computer)
Retcode=GetComputerName(Computer,Bufsize)
NullCharPos=Instr(Computer,Chr(0))
If NullCharPos>0 then
Computer=Left(Computer,NullCharPos-1)
Else
Computer=""
Endif
End Function
For More Details And API EMail Me.
-
Feb 15th, 2001, 10:12 PM
#5
Thread Starter
New Member
Thank you. That was exactly what i needed. thank u all..!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|